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