NCBI C++ ToolKit
ncbi_connutil.h
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef CONNECT___NCBI_CONNUTIL__H
2 #define CONNECT___NCBI_CONNUTIL__H
3 
4 /* $Id: ncbi_connutil.h 98705 2022-12-21 21:59:38Z lavr $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Denis Vakatov, Anton Lavrentiev
30  *
31  * File Description:
32  * Auxiliary API to:
33  * 1.Retrieve connection related info from the registry:
34  * ConnNetInfo_GetValue()
35  * ConnNetInfo_Boolean()
36  * SConnNetInfo
37  * ConnNetInfo_Create()
38  * ConnNetInfo_Clone()
39  * ConnNetInfo_SetPath()
40  * ConnNetInfo_AddPath()
41  * ConnNetInfo_SetArgs()
42  * ConnNetInfo_SetFrag()
43  * ConnNetInfo_GetArgs()
44  * ConnNetInfo_AppendArg()
45  * ConnNetInfo_PrependArg()
46  * ConnNetInfo_DeleteArg()
47  * ConnNetInfo_DeleteAllArgs()
48  * ConnNetInfo_PreOverrideArg()
49  * ConnNetInfo_PostOverrideArg()
50  * ConnNetInfo_SetupStandardArgs()
51  * ConnNetInfo_SetUserHeader()
52  * ConnNetInfo_AppendUserHeader()
53  * ConnNetInfo_OverrideUserHeader()
54  * ConnNetInfo_ExtendUserHeader()
55  * ConnNetInfo_DeleteUserHeader()
56  * ConnNetInfo_SetTimeout()
57  * ConnNetInfo_ParseURL()
58  * ConnNetInfo_URL()
59  * ConnNetInfo_Log()
60  * ConnNetInfo_Destroy()
61  * #define REG_CONN_***
62  * #define DEF_CONN_***
63  *
64  * 2.Make a connection via an URL:
65  * URL_Connect[Ex]()
66  *
67  * 3.Search for a token in an input stream (either CONN, SOCK, or BUF):
68  * CONN_StripToPattern()
69  * SOCK_StripToPattern()
70  * BUF_StripToPattern()
71  *
72  * 4.Perform URL encoding/decoding of data:
73  * URL_Encode[Ex]()
74  * URL_Decode[Ex]()
75  *
76  * 5.Compose or parse NCBI-specific Content-Type's:
77  * EMIME_Type
78  * EMIME_SubType
79  * EMIME_Encoding
80  * MIME_ComposeContentType[Ex]()
81  * MIME_ParseContentType()
82  *
83  */
84 
85 #include <connect/ncbi_buffer.h>
87 
88 
89 /* Well-known port values */
90 #define CONN_PORT_FTP 21
91 #define CONN_PORT_SSH 22
92 #define CONN_PORT_SMTP 25
93 #define CONN_PORT_HTTP 80
94 #define CONN_PORT_HTTPS 443
95 
96 /* SConnNetInfo's field lengths NOT including the terminating '\0's */
97 #define CONN_USER_LEN 63
98 #define CONN_PASS_LEN 63
99 #define CONN_HOST_LEN 255
100 #define CONN_PATH_LEN 4095 /* including arguments and a fragment */
101 
102 
103 /** @addtogroup UtilityFunc
104  *
105  * @{
106  */
107 
108 
109 #ifdef __cplusplus
110 extern "C" {
111 #endif
112 
113 
114 typedef enum {
116  /* HTTP/1.0 */
117  eReqMethod_Get, /* 1 */
121  /* HTTP/1.1 */
128  eReqMethod_Put = 16, /* 16 */
132  eReqMethod_Options /* 20 */
134 
135 typedef unsigned TReqMethod; /* EReqMethod or (EReqMethod | eReqMethod_v1) */
136 
137 
138 typedef enum {
143  eURL_Ftp
145 
146 typedef unsigned EBURLScheme;
147 
148 
149 typedef enum {
150  eFWMode_Legacy = 0, /**< Relay, no firewall */
151  eFWMode_Adaptive = 1, /**< Regular firewall ports first, then fallback */
152  eFWMode_Firewall = 2, /**< Regular firewall ports only, no fallback */
153  eFWMode_Fallback = 3 /**< Fallback ports only (w/o trying any regular) */
155 
156 typedef unsigned EBFWMode;
157 
158 
159 typedef enum {
164 
165 typedef unsigned EBDebugPrintout;
166 
167 
168 /* Network connection-related configurable informational structure.
169  * ATTENTION: Do NOT fill out this structure (SConnNetInfo) "from scratch"!
170  * Instead, use ConnNetInfo_Create() described below to create it,
171  * and then fix (hard-code) some fields using the ConnNetInfo API,
172  * or directly as the last resort if really necessary.
173  * NOTE1: Not every field may be fully utilized throughout the library.
174  * NOTE2: HTTP passwords can be either clear text or Base-64 encoded value
175  * enclosed in square brackets [] (which are not Base-64 charset).
176  * For encoding / decoding, one can use the command-line OpenSSL:
177  * echo [-n] "password|base64value" | openssl enc {-e|-d} -base64
178  * or an online tool (search the Web for "base64 online").
179  * NOTE3: The NCBI_CRED credentials are stored by the handle value and are
180  * not otherwise managed (reallocated / duplicated) by the API:
181  * they are passed strictly "as-is" to the lower levels of the SSL.
182  */
183 typedef struct { /* NCBI_FAKE_WARNING: ICC */
184  char client_host[CONN_HOST_LEN+1]; /*client hostname('\0'=def)*/
185  TReqMethod req_method:5; /* method to use in the request (HTTP) */
186  EBURLScheme scheme:3; /* only pre-defined types (limited) */
187  unsigned external:1; /* mark service request as external */
188  EBFWMode firewall:2; /* to use firewall (relay otherwise) */
189  unsigned stateless:1; /* to connect in HTTP-like fashion only*/
190  unsigned lb_disable:1; /* to disable local load-balancing */
191  unsigned http_version:1; /* HTTP/1.v (or selected by req_method)*/
192  EBDebugPrintout debug_printout:2; /* switch to printout some debug info */
193  unsigned http_push_auth:1; /* push authorize tags even w/o 401/407*/
194  unsigned http_proxy_leak:1;/* TRUE when may fallback to direct */
195  unsigned http_proxy_skip:1;/* TRUE when *NOT* to read $http_proxy */
196  unsigned http_proxy_only:1;/* TRUE when proxy is from $http_proxy */
197  unsigned reserved:12; /* MBZ */
198  char user[CONN_USER_LEN+1]; /* username (if spec'd or req'd) */
199  char pass[CONN_PASS_LEN+1]; /* password (for non-empty user) */
200  char host[CONN_HOST_LEN+1]; /* host name to connect to */
201  unsigned short port; /* port # (host byte order) */
202  char path[CONN_PATH_LEN+1]; /* path (incl. args and frag) */
203  char http_proxy_host[CONN_HOST_LEN+1]; /* HTTP proxy server */
204  unsigned short http_proxy_port; /* port # of HTTP proxy server */
205  char http_proxy_user[CONN_USER_LEN+1]; /* HTTP proxy username */
206  char http_proxy_pass[CONN_PASS_LEN+1]; /* HTTP proxy password */
207  unsigned short max_try; /* max. # of attempts to connect (>= 1)*/
208  unsigned short unused; /* MBZ; 8-byte alignment */
209  const STimeout* timeout; /* ptr to I/O timeout(infinite if NULL)*/
210  const char* http_user_header; /* user header to add to HTTP request */
211  const char* http_referer; /* request referrer (when spec'd) */
212  NCBI_CRED credentials; /* connection credentials (optional) */
213 
214  /* the following fields are for internal use only -- look but don't touch*/
215  unsigned int magic; /* to detect version skew */
216  STimeout tmo; /* default storage for finite timeout */
217  const char svc[1]; /* service which this info created for */
218 } SConnNetInfo;
219 
220 
221 /* Defaults and the registry entry names for "SConnNetInfo" fields
222  */
223 #define DEF_CONN_REG_SECTION "CONN"
224 
225 #define REG_CONN_REQ_METHOD "REQ_METHOD"
226 #define DEF_CONN_REQ_METHOD "ANY"
227 
228 #define REG_CONN_USER "USER"
229 #define DEF_CONN_USER ""
230 
231 #define REG_CONN_PASS "PASS"
232 #define DEF_CONN_PASS ""
233 
234 #define REG_CONN_HOST "HOST"
235 #define DEF_CONN_HOST "www.ncbi.nlm.nih.gov"
236 
237 #define REG_CONN_PORT "PORT"
238 #define DEF_CONN_PORT 0/*default*/
239 
240 #define REG_CONN_PATH "PATH"
241 #define DEF_CONN_PATH "/Service/dispd.cgi"
242 
243 #define REG_CONN_ARGS "ARGS"
244 #define DEF_CONN_ARGS ""
245 
246 #define REG_CONN_HTTP_PROXY_HOST "HTTP_PROXY_HOST"
247 #define DEF_CONN_HTTP_PROXY_HOST ""
248 
249 #define REG_CONN_HTTP_PROXY_PORT "HTTP_PROXY_PORT"
250 #define DEF_CONN_HTTP_PROXY_PORT ""
251 
252 #define REG_CONN_HTTP_PROXY_USER "HTTP_PROXY_USER"
253 #define DEF_CONN_HTTP_PROXY_USER ""
254 
255 #define REG_CONN_HTTP_PROXY_PASS "HTTP_PROXY_PASS"
256 #define DEF_CONN_HTTP_PROXY_PASS ""
257 
258 #define REG_CONN_HTTP_PROXY_LEAK "HTTP_PROXY_LEAK"
259 #define DEF_CONN_HTTP_PROXY_LEAK ""
260 
261 #define REG_CONN_HTTP_PROXY_SKIP "HTTP_PROXY_SKIP"
262 #define DEF_CONN_HTTP_PROXY_SKIP ""
263 
264 #define REG_CONN_HTTP_PUSH_AUTH "HTTP_PUSH_AUTH"
265 #define DEF_CONN_HTTP_PUSH_AUTH ""
266 
267 #define REG_CONN_TIMEOUT "TIMEOUT"
268 #define DEF_CONN_TIMEOUT 30.0
269 
270 #define REG_CONN_MAX_TRY "MAX_TRY"
271 #define DEF_CONN_MAX_TRY 3
272 
273 #define REG_CONN_EXTERNAL "EXTERNAL"
274 #define DEF_CONN_EXTERNAL ""
275 
276 #define REG_CONN_FIREWALL "FIREWALL"
277 #define DEF_CONN_FIREWALL ""
278 
279 #define REG_CONN_STATELESS "STATELESS"
280 #define DEF_CONN_STATELESS ""
281 
282 #define REG_CONN_LB_DISABLE "LB_DISABLE"
283 #define DEF_CONN_LB_DISABLE ""
284 
285 #define REG_CONN_HTTP_VERSION "HTTP_VERSION"
286 #define DEF_CONN_HTTP_VERSION 0
287 
288 #define REG_CONN_DEBUG_PRINTOUT "DEBUG_PRINTOUT"
289 #define DEF_CONN_DEBUG_PRINTOUT ""
290 
291 #define REG_CONN_HTTP_USER_HEADER "HTTP_USER_HEADER"
292 #define DEF_CONN_HTTP_USER_HEADER ""
293 
294 #define REG_CONN_HTTP_REFERER "HTTP_REFERER"
295 #define DEF_CONN_HTTP_REFERER 0
296 
297 /* Environment/registry keys that are *not* kept in SConnNetInfo */
298 #define REG_CONN_LOCAL_ENABLE "LOCAL_ENABLE"
299 #define REG_CONN_LBSMD_DISABLE "LBSMD_DISABLE"
300 #define REG_CONN_LBDNS_ENABLE "LBDNS_ENABLE"
301 #define REG_CONN_LINKERD_ENABLE "LINKERD_ENABLE"
302 #define REG_CONN_NAMERD_ENABLE "NAMERD_ENABLE"
303 #define REG_CONN_DISPD_DISABLE "DISPD_DISABLE"
304 
305 /* Implicit server type (LINKERD/NAMERD) */
306 #define REG_CONN_IMPLICIT_SERVER_TYPE "IMPLICIT_SERVER_TYPE"
307 
308 /* Substitute (redirected) service name */
309 #define REG_CONN_SERVICE_NAME DEF_CONN_REG_SECTION "_" "SERVICE_NAME"
310 
311 /* Local service dispatcher */
312 #define REG_CONN_LOCAL_SERVICES DEF_CONN_REG_SECTION "_" "LOCAL_SERVICES"
313 #define REG_CONN_LOCAL_SERVER DEF_CONN_REG_SECTION "_" "LOCAL_SERVER"
314 
315 /* LBDNS settings */
316 #define REG_CONN_LBDNS_DOMAIN DEF_CONN_REG_SECTION "_" "LBDNS_DOMAIN"
317 #define REG_CONN_LBDNS_DEBUG DEF_CONN_REG_SECTION "_" "LBDNS_DEBUG"
318 #define REG_CONN_LBDNS_HOST DEF_CONN_REG_SECTION "_" "LBDNS_HOST"
319 #define REG_CONN_LBDNS_PORT DEF_CONN_REG_SECTION "_" "LBDNS_PORT"
320 
321 
322 /* Local IP table */
323 #define DEF_CONN_LOCAL_IPS "LOCAL_IPS"
324 #define REG_CONN_LOCAL_IPS DEF_CONN_REG_SECTION "_" DEF_CONN_LOCAL_IPS
325 #define DEF_CONN_LOCAL_IPS_DISABLE "NONE"
326 
327 
328 /* Lookup "param" in the registry / environment. "param" is usually all-caps.
329  * If "param" does not begin with "CONN_", then "CONN_" or "_CONN_" gets
330  * automatically injected in all lookups listed below, unless otherwise noted.
331  * The order of search is the following (the first match causes to return):
332  * 1. Environment variable "service_CONN_param", where "service" gets dashes
333  * (if any) replaced with underscores: first looked up converted to all
334  * uppercase, and if that failed, then looked up with the original case in
335  * the "service" part;
336  * 2. Registry key "CONN_param" in the section '["service"]';
337  * 3. Environment setting "CONN_param" (in all upper-case);
338  * 4. Registry key "param" (with the leading "CONN_" stripped) in the default
339  * section "[CONN]".
340  * Steps 1 & 2 skipped for "service" passed as either NULL or empty ("").
341  * Steps 3 & 4 skipped for a non-empty "service" and a "param" that already
342  * begins with "CONN_".
343  * If the found match's value has enveloping quotes (either single '' or
344  * double ""), then they are stripped from the result, which can then become
345  * empty.
346  * Up to "value_size" bytes (including the terminating '\0') of the result get
347  * copied into the "value" buffer (which may cause truncation!). When no match
348  * is found, the "value" gets filled up to "value_size" bytes with "def_value"
349  * (or an empty string). Return 0 on out of memory (including "value_size"
350  * given as 0) or value truncation; otherwise, return "value".
351  * @note
352  * "value" is always '\0'-terminated if "value_size" is greater than 0.
353  */
355 (const char* service,
356  const char* param,
357  char* value,
358  size_t value_size,
359  const char* def_value /* NB: both NULL and "" have the same effect */
360  );
361 
362 
363 /* Return non-zero if "str" (when non-NULL, non-empty) represents a boolean
364  * true value; return 0 otherwise.
365  */
366 extern NCBI_XCONNECT_EXPORT int/*bool*/ ConnNetInfo_Boolean
367 (const char* str
368  );
369 
370 
371 /* This function fills out the "*info" structure using registry entries named
372  * (see above) in the REG_CONN_<NAME> macros (defaults are in DEF_CONN_<NAME>):
373  *
374  * -- INFO FIELD -- ----- NAME ----- ----------- REMARKS/EXAMPLES ----------
375  * client_host (auto-assigned) local host name filled in automatically
376  * req_method REQ_METHOD only "GET"/"POST"/"ANY" allowed
377  * user USER
378  * pass PASS
379  * host HOST
380  * port PORT
381  * path PATH
382  * ARGS combined in "path" now -- use API calls
383  * http_version HTTP_VERSION HTTP version override
384  * http_proxy_host HTTP_PROXY_HOST if empty http_proxy_port is set to 0
385  * http_proxy_port HTTP_PROXY_PORT no HTTP proxy if 0
386  * http_proxy_user HTTP_PROXY_USER
387  * http_proxy_pass HTTP_PROXY_PASS
388  * http_proxy_leak HTTP_PROXY_LEAK 1 means to also re-try w/o the proxy
389  * http_proxy_skip HTTP_PROXY_SKIP 1 means to skip $http_proxy environment
390  * http_proxy_only (auto-assigned) 1 means proxy loaded from $http_proxy
391  * http_push_auth HTTP_PUSH_AUTH 1 if to send credentials pre-emptively
392  * timeout TIMEOUT "<sec>.<usec>": "3.00005", "infinite"
393  * max_try MAX_TRY
394  * external EXTERNAL 1 to mark requests as "external"
395  * firewall FIREWALL
396  * stateless STATELESS
397  * lb_disable LB_DISABLE obsolete, disables the "LBSMD" mapper
398  * debug_printout DEBUG_PRINTOUT "SOME"(eqv "TRUE") / "DATA"(eqv "ALL")
399  * http_user_header HTTP_USER_HEADER "\r\n" (if missing) is auto-appended
400  * http_referer HTTP_REFERER may be assigned automatically
401  * svc SERVICE_NAME no search/no value without service
402  *
403  * A value of the field NAME is first looked up in the environment variable of
404  * the form <service>_CONN_<NAME>; then in the current corelib registry, in
405  * the section 'service' by using the CONN_<NAME> key; then in the environment
406  * variable again, but using the name CONN_<NAME>; and finally, in the default
407  * registry section (DEF_CONN_REG_SECTION), using just <NAME>. If the service
408  * is NULL or empty then the first two steps in the above lookup are skipped.
409  *
410  * For default values see right above, within macros DEF_CONN_<NAME>.
411  *
412  * @sa
413  * ConnNetInfo_GetValue
414  */
416 (const char* service
417  );
418 
419 
420 /* Make an exact and independent copy of "*net_info".
421  */
423 (const SConnNetInfo* net_info
424  );
425 
426 
427 /* Convenience routines to manipulate URL path, arguments, and fragment, all of
428  * which are now stored combined in SConnNetInfo::path.
429  *
430  * @warning
431  * Arguments provided to the SConnNetInfo::path manipulation routines below
432  * may not point to anywhere inside the path stored within the SConnNetInfo
433  * structure, which is being modified.
434  *
435  * All argument modification routines below assume that "arg" is either a
436  * single arg name or an "arg=val" pair (a fragment part, separated by '#', if
437  * any, is ignored).
438  * In the former case, an additional "val" may be supplied separately (and will
439  * be prepended with '='). In the latter case, also having a non-zero string
440  * in the "val" argument may result in an incorrect behavior. The ampersand
441  * ('&') gets automatically managed to keep the arg list consistent.
442  *
443  * Return values (if non-void): non-zero(true) on success; 0(false) on error.
444  */
445 
446 /* Set the path part in the path element.
447  * New path may also contain either or both the argument part (separated by
448  * '?'), and the fragment part (separated by '#'), in this order. The new path
449  * will replace the existing one up to and including the last specified part,
450  * preserving the remainder. Thus, "" causes only the path part to be removed
451  * (leaving any existing argument(s) and fragment alone). However, "#" will
452  * cause to clear the entire path (single trailing '#' is never stored, but is
453  * always considered). Also, NULL clears the entire path element. */
454 extern NCBI_XCONNECT_EXPORT int/*bool*/ ConnNetInfo_SetPath
455 (SConnNetInfo* net_info,
456  const char* path);
457 
458 /* Add the path part to the path element.
459  * New path may also contain either or both the argument part (separated by
460  * '?'), and the fragment part (separated by '#'), in this order. The new path
461  * will extend the existing one up to and including the last specified part,
462  * preserving the remainder. If the new path begins with a slash ('/'), the
463  * extension starts at the end of the existing path, making sure the slash is
464  * not doubled; if the new path does not begin with a slash, the extension
465  * starts after the last slash found in the existing path, or at the very
466  * beginning, if there was no slash in the old path. Note that NULL or ""
467  * cause no effect.
468  *
469  * Corner cases: if the new "path" begins with the arguments part ('?'), then
470  * the path part will be retained but the arguments part (and possibly the
471  * fragment, too, if specified) will be replaced. If the new "path" begins
472  * with '#', then only the fragment part is replaced ("#" causes the fragment
473  * to be dropped, and the single trailing '#' will not be stored).
474  *
475  * Example: "/path1/path2?args1&args2#" extends the existing path part with
476  * appending two more levels "/path1/path2" to it, replaces all existing
477  * arguments with "args1&args2", and drops any exising fragment (not storing
478  * the trailing '#'). If the trailing '#' wasn't specified, the old fragment
479  * (if any) would have been kept intact. "/path1/path2#frag" would work
480  * similarly with path, but drop all existing args, and replace the existing
481  * fragment.
482  *
483  * Note that incoming "path" is assumed to be minimally syntactically correct,
484  * so passing "/path1/path2?#frag" is allowed but will create the path element
485  * with a lone '?' character, just as given.
486  */
487 extern NCBI_XCONNECT_EXPORT int/*bool*/ ConnNetInfo_AddPath
488 (SConnNetInfo* net_info,
489  const char* path);
490 
491 /* Set the args part (which may contain or just be a #frag part) in the path
492  * element, adding the '?' separator automatically, if needed. If the fragment
493  * is missing from the new args, the existing one will be preserved; and if
494  * no arguments are provided before the new fragment, that part of the exising
495  * arguments will not get modified. Thus, "" causes all arguments but the
496  * fragment to be removed. NULL clears all existing args and frag. */
497 extern NCBI_XCONNECT_EXPORT int/*bool*/ ConnNetInfo_SetArgs
498 (SConnNetInfo* net_info,
499  const char* args);
500 
501 /* Set fragment part only; delete if "frag" is NULL, "", or "#". The passed
502  * string may start with '#'; otherwise, the '#' separator will be added to
503  * the path element. */
504 extern NCBI_XCONNECT_EXPORT int/*bool*/ ConnNetInfo_SetFrag
505 (SConnNetInfo* net_info,
506  const char* frag);
507 
508 /* Return args (without leading '?' but with leading '#' if fragment only. */
509 extern NCBI_XCONNECT_EXPORT const char* ConnNetInfo_GetArgs
510 (const SConnNetInfo* net_info
511  );
512 
513 /* Append an argument to the end of the list, preserving any #frag if there. */
515 (SConnNetInfo* net_info,
516  const char* arg,
517  const char* val
518  );
519 
520 /* Insert an argument at the front of the list, preserving any #frag part. */
522 (SConnNetInfo* net_info,
523  const char* arg,
524  const char* val
525  );
526 
527 /* Delete an argument from the list of arguments in the path element. In case
528  * the passed arg is specified as "arg=val&arg2...", the value as well as any
529  * successive arguments are ignored in the search for the matching argument.
530  * Return zero if no arg was found; non-zero if it was found and deleted.
531  * Any existing #frag part is not modified. */
533 (SConnNetInfo* net_info,
534  const char* arg
535  );
536 
537 /* Delete all arguments specified in "args" (regardless of their values) from
538  * the path element. Any existing #frag part if not modified. */
540 (SConnNetInfo* net_info,
541  const char* args
542  );
543 
544 /* Same as sequence DeleteAll(arg) then Prepend(arg, val), see above. */
546 (SConnNetInfo* net_info,
547  const char* arg,
548  const char* val
549  );
550 
551 /* Same as sequence DeleteAll(arg) then Append(arg, val), see above. */
553 (SConnNetInfo* net_info,
554  const char* arg,
555  const char* val
556  );
557 
558 
559 /* Set up standard arguments: service(as passed), address, and platform.
560  * Also, set up the "User-Agent:" HTTP header (using CORE_GetAppName()) in
561  * SConnNetInfo::http_user_header. Return non-zero on success; zero on error.
562  * @note
563  * "service" passed as NULL does not add any service argument, yet "service"
564  * passed as empty string ("") removes the service argument.
565  * @note
566  * The call can sacrifice the platform and address (in this order) in order to
567  * fit the service argument (when provided non-empty).
568  * @sa
569  * CORE_GetAppName, CORE_GetPlatform
570  */
572 (SConnNetInfo* net_info,
573  const char* service
574  );
575 
576 
577 /* Set new user header (discard previously set header, if any). Remove the old
578  * header (if any) only, if "header" is NULL or empty ("" or all blanks).
579  * @warning
580  * New "header" may not be any part of the header kept in the structure.
581  * Return non-zero if successful; otherwise, return 0 to indicate an error.
582  */
584 (SConnNetInfo* net_info,
585  const char* header
586  );
587 
588 
589 /* Append to user header (same as ConnNetInfo_SetUserHeader() if no previous
590  * header was set); do nothing if the provided "header" is NULL or empty.
591  * @warning
592  * New "header" may not be any part of the header kept in the structure.
593  * Return non-zero if successful; otherwise, return 0 to indicate an error.
594  */
596 (SConnNetInfo* net_info,
597  const char* header
598  );
599 
600 
601 /* Override user header.
602  * Tags replaced (case-insensitively), and tags with empty values effectively
603  * delete all existing occurrences of the matching tags from the old user
604  * header, e.g. "My-Tag:\r\n" deletes all appearences of "My-Tag: [<value>]"
605  * from the user header, regardless of the "<value>" (if any).
606  * Unmatched tags with non-empty values are simply added to the existing user
607  * header (as with "Append" above). No-op if "header" is an empty string ("").
608  * @note
609  * New "header" may be part of the current header from the structure.
610  * Return non-zero if successful, otherwise return 0 to indicate an error.
611  */
613 (SConnNetInfo* net_info,
614  const char* header
615  );
616 
617 
618 /* Extend user header.
619  * Existing tags matching (case-insensitively) first appearances of those
620  * from "header" get appended with the new value (separated by a space) if the
621  * added value is non-empty, otherwise, the tags are left untouched. However,
622  * if the new tag value matches (case-insensitively) tag's value already in the
623  * header, the new value does not get added (to avoid duplicates).
624  * All other new tags from "header" with non-empty values get added at the end
625  * of the user header (as with "Append" above).
626  * @note
627  * New "header" may be part of the current header from the structure.
628  * Return non-zero if successful, otherwise return 0 to indicate an error.
629  */
631 (SConnNetInfo* net_info,
632  const char* header
633  );
634 
635 
636 /* Delete entries from current user header, if their tags match those passed in
637  * "header" (regardless of the values, if any).
638  * @note
639  * New "header" may be part of the current header from the structure.
640  */
642 (SConnNetInfo* net_info,
643  const char* header
644  );
645 
646 
647 /* Set the timeout. Accepted values can include a valid pointer (to a finite
648  * timeout) or kInfiniteTimeout (or 0) to denote the infinite timeout value.
649  * Note that kDefaultTimeout as a pointer value is not accepted.
650  * Return non-zero (TRUE) on success, or zero (FALSE) on error.
651  */
653 (SConnNetInfo* net_info,
654  const STimeout* timeout
655  );
656 
657 
658 /* Parse URL into "*net_info", using defaults provided via "*net_info".
659  * In case of a relative URL, only those URL elements provided in it,
660  * will get replaced in the resultant "*net_info".
661  * Return non-zero if successful, otherwise return 0 to indicate an error.
662  */
664 (SConnNetInfo* net_info,
665  const char* url
666  );
667 
668 
669 /* Reconstruct text URL out of the SConnNetInfo's components (excluding
670  * username:password for safety reasons). Return NULL on error.
671  * Returned non-NULL string must be free()'d when no longer needed.
672  */
674 (const SConnNetInfo* net_info
675  );
676 
677 
678 /* Log the contents of "*net_info" into specified "log" with severity "sev".
679  */
681 (const SConnNetInfo* net_info,
682  ELOG_Level sev,
683  LOG log
684  );
685 
686 
687 /* Destroy and deallocate "net_info" (if not NULL; otherwise, do nothing).
688  */
690 (SConnNetInfo* net_info
691  );
692 
693 
694 
695 /* Very low-level HTTP initiation routine. Regular use is highly discouraged.
696  * Instead, please consider using higher level APIs such as HTTP connections
697  * or streams:
698  * @sa
699  * HTTP_CreateConnector, CConn_HttpStream
700  *
701  * Hit a URL "http[s]://host[:port]/path[?args]" with the following request
702  * (argument substitution is shown as enclosed in angle brackets (not present
703  * in the actual request), and all optional parts shown in square brackets):
704  *
705  * METHOD <path>[?<args>] HTTP/1.x\r\n
706  * [Content-Length: <content_length>\r\n]
707  * [<user_header>\r\n]\r\n
708  *
709  * If "port" is not specified (0) it will be assigned automatically to a
710  * well-known standard value depending on the "fSOCK_Secure" bit in the "flags"
711  * parameter, when connecting to an HTTP server.
712  *
713  * A protocol version "1.x" is selected by the "req_method"'s value, and can be
714  * either 1.0 or 1.1. METHOD can be any of those of EReqMethod.
715  *
716  * @note that unlike the now-deprecated URL_Connect(), this call never encodes
717  * any "args", and never auto-inserts any "Host:" tag into the headers (unless
718  * provided by the "user_header" argument).
719  *
720  * Request method "eReqMethod_Any/11" selects an appropriate method depending
721  * on the value of "content_length": results in GET when no content is
722  * expected ("content_length"==0), and POST when "content_length" is non-zero.
723  *
724  * The "content_length" parameter must specify the exact(!) amount of data that
725  * is going to be sent (0 if none) to HTTP server. The "Content-Length" header
726  * with the specified value gets added to all legal requests (but GET / HEAD /
727  * CONNECT). Special case of (-1L) suppresses the header.
728  * Note that if "user_header" contains a "Transfer-Encoding:" header tag, then
729  * "content_length" *must* be passed as (-1L) (RFC7230, 3.3.2).
730  *
731  * Alternatively, "content_length" can specify the amount of initial data to be
732  * sent with a CONNECT request into the established tunnel, and held by the
733  * "args" parameter (although, no header tag will get added to the HTTP header
734  * in that case, see below). Note, however, that RFC7231, 4.3.6 warns that the
735  * behavior of sending a payload with CONNECT is not well-defined.
736  *
737  * If the string "user_header" is not NULL/empty, it will be stripped off any
738  * surrounding white space (including "\r\n"), then get added to the HTTP
739  * header, followed by the header termination sequence of "\r\n\r\n".
740  * @note that any interior whitespace in "user_header" is not analyzed/guarded.
741  *
742  * The "cred" parameter is only used to pass additional connection credentials
743  * for secure connections, and is ignored otherwise.
744  *
745  * If the request method contains "eReqMethod_Connect", then the connection is
746  * assumed to be tunneled via a proxy, so "path" must specify a "host:port"
747  * pair to connect to; "content_length" can provide initial size of the data
748  * to be tunneled, in which case "args" must be a pointer to such data, but no
749  * "Content-Length:" header tag will get added.
750  *
751  * If "*sock" is non-NULL, the call _does not_ create a new socket, but builds
752  * an HTTP(S) data stream on top of the passed socket. Regardless of the
753  * completion status, the original SOCK handle will be closed as if with
754  * SOCK_Destroy(). In case of success, a new SOCK handle will be returned via
755  * the same last parameter; yet in case of errors, the last parameter will be
756  * updated to read as NULL.
757  *
758  * On success, return eIO_Success and non-NULL handle of a socket via the last
759  * parameter.
760  *
761  * The returned socket must be exipicitly closed by "SOCK_Close[Ex]()" when no
762  * longer needed.
763  *
764  * NOTE: The returned socket may not be immediately readable/writeable if
765  * either open or read/write timeouts were passed as {0,0}, meaning that
766  * both connection and HTTP header write operation may still be pending
767  * in the resultant socket. It is responsibility of the application to
768  * analyze the actual socket state in this case (see "ncbi_socket.h").
769  * @sa
770  * SOCK_Create, SOCK_CreateOnTop, SOCK_Wait, SOCK_Status,
771  * SOCK_Abort, SOCK_Destroy, SOCK_CloseEx
772  */
774 (const char* host, /* must be provided */
775  unsigned short port, /* may be 0, defaulted to either 80 or 443 */
776  const char* path, /* must be provided */
777  const char* args, /* may be NULL or empty */
778  TReqMethod req_method, /* ANY selects method by "content_length" */
779  size_t content_length, /* may not be used with HEAD or GET */
780  const STimeout* o_timeout, /* timeout for an OPEN stage */
781  const STimeout* rw_timeout, /* timeout for READ and WRITE */
782  const char* user_header, /* should include "Host:" in most cases */
783  NCBI_CRED cred, /* connection credentials, if any */
784  TSOCK_Flags flags, /* additional socket requirements */
785  SOCK* sock /* returned socket (on eIO_Success only) */
786  );
787 
788 
789 /* Equivalent to the above except that it returns a non-NULL socket handle
790  * on success, and NULL on error without providing a reason for the failure.
791  *
792  * @note that only HTTP/1.0 methods can be used with this call. For HTTP/1.1
793  * see URL_ConnectEx().
794  *
795  * For GET/POST(or ANY) methods the call attempts to provide a "Host:" HTTP tag
796  * using information from the "host" and "port" parameters if such a tag is not
797  * found within "user_header" (notwithstanding below, the port part of the tag
798  * does not get added for non-specified "port" passed as 0). Note that the
799  * result of the above-said auto-magic can be incorrect for HTTP retrievals
800  * through a proxy server (since the built tag would correspond to the proxy
801  * connection point, but not the actual server as it should have):
802  *
803  * Host: host[:port]\r\n
804  *
805  * @warning DO NOT USE THIS CALL!
806  *
807  * CAUTION: If requested, "args" can get encoded but will do that as a whole!
808  *
809  * @sa
810  * URL_ConnectEx
811  */
812 #ifndef NCBI_DEPRECATED
813 # define NCBI_CONNUTIL_DEPRECATED
814 #else
815 # define NCBI_CONNUTIL_DEPRECATED NCBI_DEPRECATED
816 #endif
818 (const char* host, /* must be provided */
819  unsigned short port, /* may be 0, defaulted to either 80 or 443 */
820  const char* path, /* must be provided */
821  const char* args, /* may be NULL or empty */
822  EReqMethod req_method, /* ANY selects method by "content_length" */
823  size_t content_length, /* may not be used with HEAD or GET */
824  const STimeout* o_timeout, /* timeout for an OPEN stage */
825  const STimeout* rw_timeout, /* timeout for READ and WRITE */
826  const char* user_header, /* may get auto-extended with a "Host" tag */
827  int/*bool*/ encode_args, /* URL-encode "args" entirely (CAUTION!) */
828  TSOCK_Flags flags /* additional socket requirements */
829  );
830 
831 
832 /** Discard all input data before (and including) the first occurrence of a
833  * "pattern". If "discard" is not NULL then add the stripped data (including
834  * the "pattern") to it. If "n_discarded" is not NULL then "*n_discarded"
835  * will get the number of actually stripped bytes. If there was some excess
836  * read, push it back to the original source (and not count as discarded).
837  * NOTE: If "pattern_size" == 0, then "pattern" is ignored (and is assumed to
838  * be NULL), and the stripping continues until EOF; if "pattern" is NULL and
839  * "pattern_size" is not 0, then exactly "pattern_size" bytes will have
840  * attempted to be stripped (unless an I/O error occurs prematurely).
841  *
842  * @return eIO_Success when the requested operation has completed successfully
843  * (pattern found, or the requested number of bytes was skipped, including when
844  * either was followed by the end-of-file condition), and if the "discard"
845  * buffer was provided, then everything skipped has been successfully stored in
846  * it. Otherwise, return other error code, and store everything read / skipped
847  * thus far in the "discard" buffer, if provided. Naturally, it never returns
848  * eIO_Success when requested to skip through the end of file, but eIO_Closed
849  * when the EOF has been reached. Note that memory allocation errors (such as
850  * unable to save skipped data in the "discard" buffer) will be assigned the
851  * eIO_Unknown code -- which as well can be returned from the failing I/O).
852  *
853  * @note To distiguish the nature of eIO_Unknown (whether it is I/O or memory)
854  * one can check the grow of the buffer size after the call, and compare it to
855  * the value of "*n_discarded": if they agree, there was an I/O error, not the
856  * buffer's.
857  */
859 (CONN conn,
860  const void* pattern,
861  size_t pattern_size,
862  BUF* discard,
863  size_t* n_discarded
864  );
865 
866 
868 (SOCK sock,
869  const void* pattern,
870  size_t pattern_size,
871  BUF* discard,
872  size_t* n_discarded
873  );
874 
875 
877 (BUF buffer,
878  const void* pattern,
879  size_t pattern_size,
880  BUF* discard,
881  size_t* n_discarded
882  );
883 
884 
885 /* URL-encode up to "src_size" symbols(bytes) from buffer "src_buf".
886  * Write the encoded data to buffer "dst_buf", but no more than "dst_size"
887  * bytes.
888  * Assign "*src_read" to the # of bytes successfully encoded from "src_buf".
889  * Assign "*dst_written" to the # of bytes written to buffer "dst_buf".
890  * @note "dst_buf" is not getting '\0'-terminated.
891  */
893 (const void* src_buf, /* [in] non-NULL */
894  size_t src_size, /* [in] */
895  size_t* src_read, /* [out] non-NULL */
896  void* dst_buf, /* [in/out] non-NULL */
897  size_t dst_size, /* [in] */
898  size_t* dst_written /* [out] non-NULL */
899  );
900 
901 
902 /* Act just like URL_Encode (see above) but caller can allow the specified
903  * non-standard URL symbols in the input buffer to be encoded "as is".
904  * The extra allowed symbols are passed in a '\0'-terminated string
905  * "allow_symbols" (it can be NULL or empty -- then this will be an exact
906  * equivalent of URL_Encode).
907  * @note "dst_buf" is not getting '\0'-terminated.
908  */
910 (const void* src_buf, /* [in] non-NULL */
911  size_t src_size, /* [in] */
912  size_t* src_read, /* [out] non-NULL */
913  void* dst_buf, /* [in/out] non-NULL */
914  size_t dst_size, /* [in] */
915  size_t* dst_written, /* [out] non-NULL */
916  const char* allow_symbols /* [in] '\0'-term */
917  );
918 
919 
920 /* URL-decode up to "src_size" symbols(bytes) from buffer "src_buf".
921  * Write the decoded data to buffer "dst_buf", but no more than "dst_size"
922  * bytes.
923  * Assign "*src_read" to the # of bytes successfully decoded from "src_buf".
924  * Assign "*dst_written" to the # of bytes written to buffer "dst_buf".
925  * Return FALSE (0) only if cannot decode anything, and an unrecoverable
926  * URL-encoding error (such as an invalid symbol or a bad "%.." sequence)
927  * has occurred.
928  * NOTE: the unfinished "%.." sequence is fine -- return TRUE, but dont
929  * "read" it.
930  */
931 extern NCBI_XCONNECT_EXPORT int/*bool*/ URL_Decode
932 (const void* src_buf, /* [in] non-NULL */
933  size_t src_size, /* [in] */
934  size_t* src_read, /* [out] non-NULL */
935  void* dst_buf, /* [in/out] non-NULL */
936  size_t dst_size, /* [in] */
937  size_t* dst_written /* [out] non-NULL */
938  );
939 
940 
941 /* Act just like URL_Decode (see above) but caller can allow the specified
942  * non-standard URL symbols in the input buffer to be decoded "as is".
943  * The extra allowed symbols are passed in a '\0'-terminated string
944  * "allow_symbols" (it can be NULL or empty -- then this will be an exact
945  * equivalent of URL_Decode).
946  */
947 extern NCBI_XCONNECT_EXPORT int/*bool*/ URL_DecodeEx
948 (const void* src_buf, /* [in] non-NULL */
949  size_t src_size, /* [in] */
950  size_t* src_read, /* [out] non-NULL */
951  void* dst_buf, /* [in/out] non-NULL */
952  size_t dst_size, /* [in] */
953  size_t* dst_written, /* [out] non-NULL */
954  const char* allow_symbols /* [in] '\0'-term */
955  );
956 
957 
958 
959 /****************************************************************************
960  * NCBI-specific MIME content type and sub-types
961  * (the API to compose and parse them)
962  * Content-Type: <type>/<MIME_ComposeSubType()>\r\n
963  *
964  * Content-Type: <type>/<subtype>-<encoding>\r\n
965  *
966  * where MIME_ComposeSubType(EMIME_SubType subtype, EMIME_Encoding encoding):
967  * "x-<subtype>-<encoding>":
968  * "x-<subtype>", "x-<subtype>-urlencoded", "x-<subtype>-<encoding>",
969  * "x-dispatch", "x-dispatch-urlencoded", "x-dispatch-<encoding>
970  * "x-asn-text", "x-asn-text-urlencoded", "x-asn-text-<encoding>
971  * "x-asn-binary", "x-asn-binary-urlencoded", "x-asn-binary-<encoding>"
972  * "x-www-form", "x-www-form-urlencoded", "x-www-form-<encoding>"
973  * "html", "html-urlencoded", "html-<encoding>"
974  * "x-unknown", "x-unknown-urlencoded", "x-unknown-<encoding>"
975  *
976  * Note: <subtype> and <encoding> are expected to contain only
977  * alphanumeric symbols, '-' and '_'. They are case-insensitive.
978  ****************************************************************************/
979 
980 
981 /* Type
982  */
983 typedef enum {
985  eMIME_T_NcbiData = 0, /* "x-ncbi-data" (NCBI-specific data) */
986  eMIME_T_Text, /* "text" */
987  eMIME_T_Application, /* "application" */
988  /* eMIME_T_???, "<type>" here go other types */
989  eMIME_T_Unknown /* "unknown" */
991 
992 
993 /* SubType
994  */
995 typedef enum {
997  eMIME_Dispatch = 0, /* "x-dispatch" (dispatcher info) */
998  eMIME_AsnText, /* "x-asn-text" (text ASN.1 data) */
999  eMIME_AsnBinary, /* "x-asn-binary" (binary ASN.1 data) */
1000  eMIME_Fasta, /* "x-fasta" (data in FASTA format) */
1001  eMIME_WwwForm, /* "x-www-form" (Web form submission) */
1002  /* standard MIMEs */
1003  eMIME_Html, /* "html" */
1004  eMIME_Plain, /* "plain" */
1005  eMIME_Xml, /* "xml" */
1006  eMIME_XmlSoap, /* "xml+soap" */
1007  eMIME_OctetStream, /* "octet-stream" */
1008  /* eMIME_???, "<subtype>" here go other NCBI subtypes */
1009  eMIME_Unknown /* "x-unknown" (arbitrary binary data) */
1011 
1012 
1013 /* Encoding
1014  */
1015 typedef enum {
1016  eENCOD_None = 0, /* "" (the content is passed "as is")*/
1017  eENCOD_Url, /* "-urlencoded" (the content is URL-encoded) */
1018  /* eENCOD_???, "-<encoding>" here go other NCBI encodings */
1019  eENCOD_Unknown /* "-encoded" (unknown encoding) */
1021 
1022 
1023 #define CONN_CONTENT_TYPE_LEN 63
1024 /* unfortunate naming, better not to use, as it is actually a size, not len */
1025 #define MAX_CONTENT_TYPE_LEN (CONN_CONTENT_TYPE_LEN+1)
1026 
1027 
1028 /* Write up to "bufsize" bytes (including the '\0' terminator) to "buf":
1029  * Content-Type: <type>/[x-]<subtype>-<encoding>\r\n
1030  * Return the "buf" pointer when successful, or NULL when failed.
1031  */
1033 (EMIME_Type type,
1034  EMIME_SubType subtype,
1035  EMIME_Encoding encoding,
1036  char* buf,
1037  size_t bufsize /* should be at least CONN_CONTENT_TYPE_LEN+1 */
1038  );
1039 
1040 /* Parse the NCBI-specific content-type; the (case-insensitive) "str"
1041  * can be in the following two formats:
1042  * Content-Type: <type>/x-<subtype>-<encoding>
1043  * <type>/x-<subtype>-<encoding>
1044  *
1045  * NOTE: all leading spaces and all trailing spaces (and any trailing symbols,
1046  * if they separated from the content type by at least one space) will
1047  * be ignored, e.g. these are valid content type strings:
1048  * " Content-Type: text/plain foobar"
1049  * " text/html \r\n barfoo baz ....\n etc"
1050  *
1051  * PERFORMANCE NOTE: this call uses dynamic heap allocations internally.
1052  *
1053  * If it does not match any of NCBI MIME type/subtypes/encodings, then
1054  * return TRUE, eMIME_T_Unknown, eMIME_Unknown or eENCOD_None, respectively.
1055  * If the passed "str" has an invalid (non-HTTP ContentType) format
1056  * (or if it is NULL/empty), then
1057  * return FALSE, eMIME_T_Undefined, eMIME_Undefined, and eENCOD_None
1058  */
1060 (const char* str, /* the HTTP "Content-Type:" header to parse */
1061  EMIME_Type* type, /* can be NULL */
1062  EMIME_SubType* subtype, /* can be NULL */
1063  EMIME_Encoding* encoding /* can be NULL */
1064  );
1065 
1066 
1067 #ifdef __cplusplus
1068 } /* extern "C" */
1069 #endif
1070 
1071 
1072 /* @} */
1073 
1074 #endif /* CONNECT___NCBI_CONNUTIL__H */
char value[7]
Definition: config.c:431
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
static uch flags
unsigned int TSOCK_Flags
bitwise "OR" of ESOCK_Flags
Definition: ncbi_socket.h:503
ELOG_Level
Log severity level.
Definition: ncbi_core.h:292
TReqMethod req_method
unsigned EBURLScheme
EURLScheme
unsigned external
unsigned lb_disable
EBFWMode firewall
int ConnNetInfo_ExtendUserHeader(SConnNetInfo *net_info, const char *header)
unsigned TReqMethod
int ConnNetInfo_AddPath(SConnNetInfo *net_info, const char *path)
int ConnNetInfo_SetupStandardArgs(SConnNetInfo *net_info, const char *service)
unsigned short http_proxy_port
unsigned short unused
int ConnNetInfo_SetTimeout(SConnNetInfo *net_info, const STimeout *timeout)
int ConnNetInfo_OverrideUserHeader(SConnNetInfo *net_info, const char *header)
void ConnNetInfo_DeleteAllArgs(SConnNetInfo *net_info, const char *args)
const STimeout * timeout
unsigned short port
int ConnNetInfo_ParseURL(SConnNetInfo *net_info, const char *url)
unsigned http_push_auth
STimeout tmo
unsigned EBFWMode
char * MIME_ComposeContentTypeEx(EMIME_Type type, EMIME_SubType subtype, EMIME_Encoding encoding, char *buf, size_t bufsize)
int ConnNetInfo_SetArgs(SConnNetInfo *net_info, const char *args)
EMIME_Type
EMIME_SubType
int ConnNetInfo_AppendUserHeader(SConnNetInfo *net_info, const char *header)
SConnNetInfo * ConnNetInfo_Clone(const SConnNetInfo *net_info)
int ConnNetInfo_AppendArg(SConnNetInfo *net_info, const char *arg, const char *val)
const char * ConnNetInfo_GetValue(const char *service, const char *param, char *value, size_t value_size, const char *def_value)
EIO_Status
I/O status.
Definition: ncbi_core.h:132
EIO_Status CONN_StripToPattern(CONN conn, const void *pattern, size_t pattern_size, BUF *discard, size_t *n_discarded)
Discard all input data before (and including) the first occurrence of a "pattern".
unsigned reserved
int URL_Decode(const void *src_buf, size_t src_size, size_t *src_read, void *dst_buf, size_t dst_size, size_t *dst_written)
const char * ConnNetInfo_GetArgs(const SConnNetInfo *net_info)
EMIME_Encoding
int ConnNetInfo_PreOverrideArg(SConnNetInfo *net_info, const char *arg, const char *val)
unsigned http_proxy_leak
EReqMethod
unsigned stateless
SOCK URL_Connect(const char *host, unsigned short port, const char *path, const char *args, EReqMethod req_method, size_t content_length, const STimeout *o_timeout, const STimeout *rw_timeout, const char *user_header, int encode_args, TSOCK_Flags flags)
EFWMode
char * ConnNetInfo_URL(const SConnNetInfo *net_info)
EDebugPrintout
unsigned EBDebugPrintout
int ConnNetInfo_PostOverrideArg(SConnNetInfo *net_info, const char *arg, const char *val)
int ConnNetInfo_SetUserHeader(SConnNetInfo *net_info, const char *header)
int MIME_ParseContentTypeEx(const char *str, EMIME_Type *type, EMIME_SubType *subtype, EMIME_Encoding *encoding)
void ConnNetInfo_DeleteUserHeader(SConnNetInfo *net_info, const char *header)
void URL_EncodeEx(const void *src_buf, size_t src_size, size_t *src_read, void *dst_buf, size_t dst_size, size_t *dst_written, const char *allow_symbols)
unsigned http_proxy_skip
void ConnNetInfo_Log(const SConnNetInfo *net_info, ELOG_Level sev, LOG log)
EBURLScheme scheme
const char * http_user_header
unsigned short max_try
int ConnNetInfo_DeleteArg(SConnNetInfo *net_info, const char *arg)
EIO_Status URL_ConnectEx(const char *host, unsigned short port, const char *path, const char *args, TReqMethod req_method, size_t content_length, const STimeout *o_timeout, const STimeout *rw_timeout, const char *user_header, NCBI_CRED cred, TSOCK_Flags flags, SOCK *sock)
NCBI_CRED credentials
EIO_Status SOCK_StripToPattern(SOCK sock, const void *pattern, size_t pattern_size, BUF *discard, size_t *n_discarded)
SConnNetInfo * ConnNetInfo_Create(const char *service)
int ConnNetInfo_PrependArg(SConnNetInfo *net_info, const char *arg, const char *val)
unsigned http_version
unsigned int magic
void URL_Encode(const void *src_buf, size_t src_size, size_t *src_read, void *dst_buf, size_t dst_size, size_t *dst_written)
#define NCBI_CONNUTIL_DEPRECATED
int ConnNetInfo_Boolean(const char *str)
EBDebugPrintout debug_printout
int URL_DecodeEx(const void *src_buf, size_t src_size, size_t *src_read, void *dst_buf, size_t dst_size, size_t *dst_written, const char *allow_symbols)
int ConnNetInfo_SetPath(SConnNetInfo *net_info, const char *path)
const char * http_referer
void ConnNetInfo_Destroy(SConnNetInfo *net_info)
int ConnNetInfo_SetFrag(SConnNetInfo *net_info, const char *frag)
unsigned http_proxy_only
EIO_Status BUF_StripToPattern(BUF buffer, const void *pattern, size_t pattern_size, BUF *discard, size_t *n_discarded)
@ eURL_Ftp
@ eURL_Unspec
@ eURL_Http
@ eURL_Https
@ eURL_File
@ eMIME_T_Application
@ eMIME_T_Undefined
@ eMIME_T_Unknown
@ eMIME_T_Text
@ eMIME_T_NcbiData
@ eMIME_OctetStream
@ eMIME_AsnText
@ eMIME_Dispatch
@ eMIME_Undefined
@ eMIME_Xml
@ eMIME_Fasta
@ eMIME_Unknown
@ eMIME_WwwForm
@ eMIME_Plain
@ eMIME_AsnBinary
@ eMIME_Html
@ eMIME_XmlSoap
@ eENCOD_None
@ eENCOD_Url
@ eENCOD_Unknown
@ eReqMethod_Options
@ eReqMethod_Trace
@ eReqMethod_Any
@ eReqMethod_v1
@ eReqMethod_Any11
@ eReqMethod_Head11
@ eReqMethod_Post11
@ eReqMethod_Put
@ eReqMethod_Delete
@ eReqMethod_Patch
@ eReqMethod_Get
@ eReqMethod_Get11
@ eReqMethod_Connect11
@ eReqMethod_Connect
@ eReqMethod_Head
@ eReqMethod_Post
@ eFWMode_Legacy
Relay, no firewall.
@ eFWMode_Firewall
Regular firewall ports only, no fallback.
@ eFWMode_Adaptive
Regular firewall ports first, then fallback.
@ eFWMode_Fallback
Fallback ports only (w/o trying any regular)
@ eDebugPrintout_Some
@ eDebugPrintout_None
@ eDebugPrintout_Data
#define NCBI_XCONNECT_EXPORT
char * buf
#define CONN_PATH_LEN
#define CONN_HOST_LEN
Definition: ncbi_connutil.h:99
#define CONN_USER_LEN
Definition: ncbi_connutil.h:97
#define CONN_PASS_LEN
Definition: ncbi_connutil.h:98
static int bufsize
Definition: pcregrep.c:162
static pcre_uint8 * buffer
Definition: pcretest.c:1051
static const char * str(char *buf, int n)
Definition: stats.c:84
Timeout structure.
Definition: ncbi_types.h:76
Definition: type.c:6
Modified on Sat Dec 09 04:45:54 2023 by modify_doxy.py rev. 669887