urldata.h 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770
  1. #ifndef HEADER_CURL_URLDATA_H
  2. #define HEADER_CURL_URLDATA_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at https://curl.haxx.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. ***************************************************************************/
  24. /* This file is for lib internal stuff */
  25. #include "curl_setup.h"
  26. #define PORT_FTP 21
  27. #define PORT_FTPS 990
  28. #define PORT_TELNET 23
  29. #define PORT_HTTP 80
  30. #define PORT_HTTPS 443
  31. #define PORT_DICT 2628
  32. #define PORT_LDAP 389
  33. #define PORT_LDAPS 636
  34. #define PORT_TFTP 69
  35. #define PORT_SSH 22
  36. #define PORT_IMAP 143
  37. #define PORT_IMAPS 993
  38. #define PORT_POP3 110
  39. #define PORT_POP3S 995
  40. #define PORT_SMB 445
  41. #define PORT_SMBS 445
  42. #define PORT_SMTP 25
  43. #define PORT_SMTPS 465 /* sometimes called SSMTP */
  44. #define PORT_RTSP 554
  45. #define PORT_RTMP 1935
  46. #define PORT_RTMPT PORT_HTTP
  47. #define PORT_RTMPS PORT_HTTPS
  48. #define PORT_GOPHER 70
  49. #define DICT_MATCH "/MATCH:"
  50. #define DICT_MATCH2 "/M:"
  51. #define DICT_MATCH3 "/FIND:"
  52. #define DICT_DEFINE "/DEFINE:"
  53. #define DICT_DEFINE2 "/D:"
  54. #define DICT_DEFINE3 "/LOOKUP:"
  55. #define CURL_DEFAULT_USER "anonymous"
  56. #define CURL_DEFAULT_PASSWORD "ftp@example.com"
  57. /* Convenience defines for checking protocols or their SSL based version. Each
  58. protocol handler should only ever have a single CURLPROTO_ in its protocol
  59. field. */
  60. #define PROTO_FAMILY_HTTP (CURLPROTO_HTTP|CURLPROTO_HTTPS)
  61. #define PROTO_FAMILY_FTP (CURLPROTO_FTP|CURLPROTO_FTPS)
  62. #define PROTO_FAMILY_POP3 (CURLPROTO_POP3|CURLPROTO_POP3S)
  63. #define PROTO_FAMILY_SMB (CURLPROTO_SMB|CURLPROTO_SMBS)
  64. #define PROTO_FAMILY_SMTP (CURLPROTO_SMTP|CURLPROTO_SMTPS)
  65. #define DEFAULT_CONNCACHE_SIZE 5
  66. /* length of longest IPv6 address string including the trailing null */
  67. #define MAX_IPADR_LEN sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")
  68. /* Default FTP/IMAP etc response timeout in milliseconds.
  69. Symbian OS panics when given a timeout much greater than 1/2 hour.
  70. */
  71. #define RESP_TIMEOUT (1800*1000)
  72. #include "cookie.h"
  73. #include "psl.h"
  74. #include "formdata.h"
  75. #ifdef HAVE_NETINET_IN_H
  76. #include <netinet/in.h>
  77. #endif
  78. #ifdef HAVE_NETINET_IN6_H
  79. #include <netinet/in6.h>
  80. #endif
  81. #include "timeval.h"
  82. #include <curl/curl.h>
  83. #include "http_chunks.h" /* for the structs and enum stuff */
  84. #include "hostip.h"
  85. #include "hash.h"
  86. #include "splay.h"
  87. /* return the count of bytes sent, or -1 on error */
  88. typedef ssize_t (Curl_send)(struct connectdata *conn, /* connection data */
  89. int sockindex, /* socketindex */
  90. const void *buf, /* data to write */
  91. size_t len, /* max amount to write */
  92. CURLcode *err); /* error to return */
  93. /* return the count of bytes read, or -1 on error */
  94. typedef ssize_t (Curl_recv)(struct connectdata *conn, /* connection data */
  95. int sockindex, /* socketindex */
  96. char *buf, /* store data here */
  97. size_t len, /* max amount to read */
  98. CURLcode *err); /* error to return */
  99. #include "mime.h"
  100. #include "imap.h"
  101. #include "pop3.h"
  102. #include "smtp.h"
  103. #include "ftp.h"
  104. #include "file.h"
  105. #include "ssh.h"
  106. #include "http.h"
  107. #include "rtsp.h"
  108. #include "smb.h"
  109. #include "wildcard.h"
  110. #include "multihandle.h"
  111. #ifdef HAVE_GSSAPI
  112. # ifdef HAVE_GSSGNU
  113. # include <gss.h>
  114. # elif defined HAVE_GSSMIT
  115. # include <gssapi/gssapi.h>
  116. # include <gssapi/gssapi_generic.h>
  117. # else
  118. # include <gssapi.h>
  119. # endif
  120. #endif
  121. #ifdef HAVE_LIBSSH2_H
  122. #include <libssh2.h>
  123. #include <libssh2_sftp.h>
  124. #endif /* HAVE_LIBSSH2_H */
  125. /* The upload buffer size, should not be smaller than CURL_MAX_WRITE_SIZE, as
  126. it needs to hold a full buffer as could be sent in a write callback.
  127. The size was 16KB for many years but was bumped to 64KB because it makes
  128. libcurl able to do significantly faster uploads in some circumstances. Even
  129. larger buffers can help further, but this is deemed a fair memory/speed
  130. compromise. */
  131. #define UPLOAD_BUFSIZE 65536
  132. /* The "master buffer" is for HTTP pipelining */
  133. #define MASTERBUF_SIZE 16384
  134. /* Initial size of the buffer to store headers in, it'll be enlarged in case
  135. of need. */
  136. #define HEADERSIZE 256
  137. #define CURLEASY_MAGIC_NUMBER 0xc0dedbadU
  138. #define GOOD_EASY_HANDLE(x) \
  139. ((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER))
  140. #ifdef HAVE_GSSAPI
  141. /* Types needed for krb5-ftp connections */
  142. struct krb5buffer {
  143. void *data;
  144. size_t size;
  145. size_t index;
  146. int eof_flag;
  147. };
  148. enum protection_level {
  149. PROT_NONE, /* first in list */
  150. PROT_CLEAR,
  151. PROT_SAFE,
  152. PROT_CONFIDENTIAL,
  153. PROT_PRIVATE,
  154. PROT_CMD,
  155. PROT_LAST /* last in list */
  156. };
  157. #endif
  158. /* enum for the nonblocking SSL connection state machine */
  159. typedef enum {
  160. ssl_connect_1,
  161. ssl_connect_2,
  162. ssl_connect_2_reading,
  163. ssl_connect_2_writing,
  164. ssl_connect_3,
  165. ssl_connect_done
  166. } ssl_connect_state;
  167. typedef enum {
  168. ssl_connection_none,
  169. ssl_connection_negotiating,
  170. ssl_connection_complete
  171. } ssl_connection_state;
  172. /* SSL backend-specific data; declared differently by each SSL backend */
  173. struct ssl_backend_data;
  174. /* struct for data related to each SSL connection */
  175. struct ssl_connect_data {
  176. /* Use ssl encrypted communications TRUE/FALSE, not necessarily using it atm
  177. but at least asked to or meaning to use it. See 'state' for the exact
  178. current state of the connection. */
  179. bool use;
  180. ssl_connection_state state;
  181. ssl_connect_state connecting_state;
  182. #if defined(USE_SSL)
  183. struct ssl_backend_data *backend;
  184. #endif
  185. };
  186. struct ssl_primary_config {
  187. long version; /* what version the client wants to use */
  188. long version_max; /* max supported version the client wants to use*/
  189. bool verifypeer; /* set TRUE if this is desired */
  190. bool verifyhost; /* set TRUE if CN/SAN must match hostname */
  191. bool verifystatus; /* set TRUE if certificate status must be checked */
  192. bool sessionid; /* cache session IDs or not */
  193. char *CApath; /* certificate dir (doesn't work on windows) */
  194. char *CAfile; /* certificate to verify peer against */
  195. char *clientcert;
  196. char *random_file; /* path to file containing "random" data */
  197. char *egdsocket; /* path to file containing the EGD daemon socket */
  198. char *cipher_list; /* list of ciphers to use */
  199. char *cipher_list13; /* list of TLS 1.3 cipher suites to use */
  200. };
  201. struct ssl_config_data {
  202. struct ssl_primary_config primary;
  203. bool enable_beast; /* especially allow this flaw for interoperability's
  204. sake*/
  205. bool no_revoke; /* disable SSL certificate revocation checks */
  206. long certverifyresult; /* result from the certificate verification */
  207. char *CRLfile; /* CRL to check certificate revocation */
  208. char *issuercert;/* optional issuer certificate filename */
  209. curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
  210. void *fsslctxp; /* parameter for call back */
  211. bool certinfo; /* gather lots of certificate info */
  212. bool falsestart;
  213. char *cert; /* client certificate file name */
  214. char *cert_type; /* format for certificate (default: PEM)*/
  215. char *key; /* private key file name */
  216. char *key_type; /* format for private key (default: PEM) */
  217. char *key_passwd; /* plain text private key password */
  218. #ifdef USE_TLS_SRP
  219. char *username; /* TLS username (for, e.g., SRP) */
  220. char *password; /* TLS password (for, e.g., SRP) */
  221. enum CURL_TLSAUTH authtype; /* TLS authentication type (default SRP) */
  222. #endif
  223. };
  224. struct ssl_general_config {
  225. size_t max_ssl_sessions; /* SSL session id cache size */
  226. };
  227. /* information stored about one single SSL session */
  228. struct curl_ssl_session {
  229. char *name; /* host name for which this ID was used */
  230. char *conn_to_host; /* host name for the connection (may be NULL) */
  231. const char *scheme; /* protocol scheme used */
  232. void *sessionid; /* as returned from the SSL layer */
  233. size_t idsize; /* if known, otherwise 0 */
  234. long age; /* just a number, the higher the more recent */
  235. int remote_port; /* remote port */
  236. int conn_to_port; /* remote port for the connection (may be -1) */
  237. struct ssl_primary_config ssl_config; /* setup for this session */
  238. };
  239. #ifdef USE_WINDOWS_SSPI
  240. #include "curl_sspi.h"
  241. #endif
  242. /* Struct used for Digest challenge-response authentication */
  243. struct digestdata {
  244. #if defined(USE_WINDOWS_SSPI)
  245. BYTE *input_token;
  246. size_t input_token_len;
  247. CtxtHandle *http_context;
  248. /* copy of user/passwd used to make the identity for http_context.
  249. either may be NULL. */
  250. char *user;
  251. char *passwd;
  252. #else
  253. char *nonce;
  254. char *cnonce;
  255. char *realm;
  256. int algo;
  257. bool stale; /* set true for re-negotiation */
  258. char *opaque;
  259. char *qop;
  260. char *algorithm;
  261. int nc; /* nounce count */
  262. bool userhash;
  263. #endif
  264. };
  265. typedef enum {
  266. NTLMSTATE_NONE,
  267. NTLMSTATE_TYPE1,
  268. NTLMSTATE_TYPE2,
  269. NTLMSTATE_TYPE3,
  270. NTLMSTATE_LAST
  271. } curlntlm;
  272. #if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
  273. #include <iconv.h>
  274. #endif
  275. /* Struct used for GSSAPI (Kerberos V5) authentication */
  276. #if defined(USE_KERBEROS5)
  277. struct kerberos5data {
  278. #if defined(USE_WINDOWS_SSPI)
  279. CredHandle *credentials;
  280. CtxtHandle *context;
  281. TCHAR *spn;
  282. SEC_WINNT_AUTH_IDENTITY identity;
  283. SEC_WINNT_AUTH_IDENTITY *p_identity;
  284. size_t token_max;
  285. BYTE *output_token;
  286. #else
  287. gss_ctx_id_t context;
  288. gss_name_t spn;
  289. #endif
  290. };
  291. #endif
  292. /* Struct used for NTLM challenge-response authentication */
  293. #if defined(USE_NTLM)
  294. struct ntlmdata {
  295. curlntlm state;
  296. #ifdef USE_WINDOWS_SSPI
  297. CredHandle *credentials;
  298. CtxtHandle *context;
  299. SEC_WINNT_AUTH_IDENTITY identity;
  300. SEC_WINNT_AUTH_IDENTITY *p_identity;
  301. size_t token_max;
  302. BYTE *output_token;
  303. BYTE *input_token;
  304. size_t input_token_len;
  305. TCHAR *spn;
  306. #else
  307. unsigned int flags;
  308. unsigned char nonce[8];
  309. void *target_info; /* TargetInfo received in the ntlm type-2 message */
  310. unsigned int target_info_len;
  311. #endif
  312. };
  313. #endif
  314. #ifdef USE_SPNEGO
  315. struct negotiatedata {
  316. /* When doing Negotiate (SPNEGO) auth, we first need to send a token
  317. and then validate the received one. */
  318. enum { GSS_AUTHNONE, GSS_AUTHRECV, GSS_AUTHSENT } state;
  319. #ifdef HAVE_GSSAPI
  320. OM_uint32 status;
  321. gss_ctx_id_t context;
  322. gss_name_t spn;
  323. gss_buffer_desc output_token;
  324. #else
  325. #ifdef USE_WINDOWS_SSPI
  326. DWORD status;
  327. CredHandle *credentials;
  328. CtxtHandle *context;
  329. SEC_WINNT_AUTH_IDENTITY identity;
  330. SEC_WINNT_AUTH_IDENTITY *p_identity;
  331. TCHAR *spn;
  332. size_t token_max;
  333. BYTE *output_token;
  334. size_t output_token_length;
  335. #endif
  336. #endif
  337. };
  338. #endif
  339. /*
  340. * Boolean values that concerns this connection.
  341. */
  342. struct ConnectBits {
  343. /* always modify bits.close with the connclose() and connkeep() macros! */
  344. bool close; /* if set, we close the connection after this request */
  345. bool reuse; /* if set, this is a re-used connection */
  346. bool conn_to_host; /* if set, this connection has a "connect to host"
  347. that overrides the host in the URL */
  348. bool conn_to_port; /* if set, this connection has a "connect to port"
  349. that overrides the port in the URL (remote port) */
  350. bool proxy; /* if set, this transfer is done through a proxy - any type */
  351. bool httpproxy; /* if set, this transfer is done through a http proxy */
  352. bool socksproxy; /* if set, this transfer is done through a socks proxy */
  353. bool user_passwd; /* do we use user+password for this connection? */
  354. bool proxy_user_passwd; /* user+password for the proxy? */
  355. bool ipv6_ip; /* we communicate with a remote site specified with pure IPv6
  356. IP address */
  357. bool ipv6; /* we communicate with a site using an IPv6 address */
  358. bool do_more; /* this is set TRUE if the ->curl_do_more() function is
  359. supposed to be called, after ->curl_do() */
  360. bool tcpconnect[2]; /* the TCP layer (or similar) is connected, this is set
  361. the first time on the first connect function call */
  362. bool protoconnstart;/* the protocol layer has STARTED its operation after
  363. the TCP layer connect */
  364. bool retry; /* this connection is about to get closed and then
  365. re-attempted at another connection. */
  366. bool tunnel_proxy; /* if CONNECT is used to "tunnel" through the proxy.
  367. This is implicit when SSL-protocols are used through
  368. proxies, but can also be enabled explicitly by
  369. apps */
  370. bool authneg; /* TRUE when the auth phase has started, which means
  371. that we are creating a request with an auth header,
  372. but it is not the final request in the auth
  373. negotiation. */
  374. bool rewindaftersend;/* TRUE when the sending couldn't be stopped even
  375. though it will be discarded. When the whole send
  376. operation is done, we must call the data rewind
  377. callback. */
  378. bool ftp_use_epsv; /* As set with CURLOPT_FTP_USE_EPSV, but if we find out
  379. EPSV doesn't work we disable it for the forthcoming
  380. requests */
  381. bool ftp_use_eprt; /* As set with CURLOPT_FTP_USE_EPRT, but if we find out
  382. EPRT doesn't work we disable it for the forthcoming
  383. requests */
  384. bool ftp_use_data_ssl; /* Enabled SSL for the data connection */
  385. bool netrc; /* name+password provided by netrc */
  386. bool userpwd_in_url; /* name+password found in url */
  387. bool stream_was_rewound; /* Indicates that the stream was rewound after a
  388. request read past the end of its response byte
  389. boundary */
  390. bool proxy_connect_closed; /* set true if a proxy disconnected the
  391. connection in a CONNECT request with auth, so
  392. that libcurl should reconnect and continue. */
  393. bool bound; /* set true if bind() has already been done on this socket/
  394. connection */
  395. bool type_set; /* type= was used in the URL */
  396. bool multiplex; /* connection is multiplexed */
  397. bool tcp_fastopen; /* use TCP Fast Open */
  398. bool tls_enable_npn; /* TLS NPN extension? */
  399. bool tls_enable_alpn; /* TLS ALPN extension? */
  400. bool proxy_ssl_connected[2]; /* TRUE when SSL initialization for HTTPS proxy
  401. is complete */
  402. bool socksproxy_connecting; /* connecting through a socks proxy */
  403. };
  404. struct hostname {
  405. char *rawalloc; /* allocated "raw" version of the name */
  406. char *encalloc; /* allocated IDN-encoded version of the name */
  407. char *name; /* name to use internally, might be encoded, might be raw */
  408. const char *dispname; /* name to display, as 'name' might be encoded */
  409. };
  410. /*
  411. * Flags on the keepon member of the Curl_transfer_keeper
  412. */
  413. #define KEEP_NONE 0
  414. #define KEEP_RECV (1<<0) /* there is or may be data to read */
  415. #define KEEP_SEND (1<<1) /* there is or may be data to write */
  416. #define KEEP_RECV_HOLD (1<<2) /* when set, no reading should be done but there
  417. might still be data to read */
  418. #define KEEP_SEND_HOLD (1<<3) /* when set, no writing should be done but there
  419. might still be data to write */
  420. #define KEEP_RECV_PAUSE (1<<4) /* reading is paused */
  421. #define KEEP_SEND_PAUSE (1<<5) /* writing is paused */
  422. #define KEEP_RECVBITS (KEEP_RECV | KEEP_RECV_HOLD | KEEP_RECV_PAUSE)
  423. #define KEEP_SENDBITS (KEEP_SEND | KEEP_SEND_HOLD | KEEP_SEND_PAUSE)
  424. #ifdef CURLRES_ASYNCH
  425. struct Curl_async {
  426. char *hostname;
  427. int port;
  428. struct Curl_dns_entry *dns;
  429. bool done; /* set TRUE when the lookup is complete */
  430. int status; /* if done is TRUE, this is the status from the callback */
  431. void *os_specific; /* 'struct thread_data' for Windows */
  432. };
  433. #endif
  434. #define FIRSTSOCKET 0
  435. #define SECONDARYSOCKET 1
  436. /* These function pointer types are here only to allow easier typecasting
  437. within the source when we need to cast between data pointers (such as NULL)
  438. and function pointers. */
  439. typedef CURLcode (*Curl_do_more_func)(struct connectdata *, int *);
  440. typedef CURLcode (*Curl_done_func)(struct connectdata *, CURLcode, bool);
  441. enum expect100 {
  442. EXP100_SEND_DATA, /* enough waiting, just send the body now */
  443. EXP100_AWAITING_CONTINUE, /* waiting for the 100 Continue header */
  444. EXP100_SENDING_REQUEST, /* still sending the request but will wait for
  445. the 100 header once done with the request */
  446. EXP100_FAILED /* used on 417 Expectation Failed */
  447. };
  448. enum upgrade101 {
  449. UPGR101_INIT, /* default state */
  450. UPGR101_REQUESTED, /* upgrade requested */
  451. UPGR101_RECEIVED, /* response received */
  452. UPGR101_WORKING /* talking upgraded protocol */
  453. };
  454. /*
  455. * Request specific data in the easy handle (Curl_easy). Previously,
  456. * these members were on the connectdata struct but since a conn struct may
  457. * now be shared between different Curl_easys, we store connection-specific
  458. * data here. This struct only keeps stuff that's interesting for *this*
  459. * request, as it will be cleared between multiple ones
  460. */
  461. struct SingleRequest {
  462. curl_off_t size; /* -1 if unknown at this point */
  463. curl_off_t *bytecountp; /* return number of bytes read or NULL */
  464. curl_off_t maxdownload; /* in bytes, the maximum amount of data to fetch,
  465. -1 means unlimited */
  466. curl_off_t *writebytecountp; /* return number of bytes written or NULL */
  467. curl_off_t bytecount; /* total number of bytes read */
  468. curl_off_t writebytecount; /* number of bytes written */
  469. long headerbytecount; /* only count received headers */
  470. long deductheadercount; /* this amount of bytes doesn't count when we check
  471. if anything has been transferred at the end of a
  472. connection. We use this counter to make only a
  473. 100 reply (without a following second response
  474. code) result in a CURLE_GOT_NOTHING error code */
  475. struct curltime start; /* transfer started at this time */
  476. struct curltime now; /* current time */
  477. bool header; /* incoming data has HTTP header */
  478. enum {
  479. HEADER_NORMAL, /* no bad header at all */
  480. HEADER_PARTHEADER, /* part of the chunk is a bad header, the rest
  481. is normal data */
  482. HEADER_ALLBAD /* all was believed to be header */
  483. } badheader; /* the header was deemed bad and will be
  484. written as body */
  485. int headerline; /* counts header lines to better track the
  486. first one */
  487. char *hbufp; /* points at *end* of header line */
  488. size_t hbuflen;
  489. char *str; /* within buf */
  490. char *str_start; /* within buf */
  491. char *end_ptr; /* within buf */
  492. char *p; /* within headerbuff */
  493. bool content_range; /* set TRUE if Content-Range: was found */
  494. curl_off_t offset; /* possible resume offset read from the
  495. Content-Range: header */
  496. int httpcode; /* error code from the 'HTTP/1.? XXX' or
  497. 'RTSP/1.? XXX' line */
  498. struct curltime start100; /* time stamp to wait for the 100 code from */
  499. enum expect100 exp100; /* expect 100 continue state */
  500. enum upgrade101 upgr101; /* 101 upgrade state */
  501. struct contenc_writer_s *writer_stack; /* Content unencoding stack. */
  502. /* See sec 3.5, RFC2616. */
  503. time_t timeofdoc;
  504. long bodywrites;
  505. char *buf;
  506. curl_socket_t maxfd;
  507. int keepon;
  508. bool upload_done; /* set to TRUE when doing chunked transfer-encoding upload
  509. and we're uploading the last chunk */
  510. bool ignorebody; /* we read a response-body but we ignore it! */
  511. bool ignorecl; /* This HTTP response has no body so we ignore the Content-
  512. Length: header */
  513. char *location; /* This points to an allocated version of the Location:
  514. header data */
  515. char *newurl; /* Set to the new URL to use when a redirect or a retry is
  516. wanted */
  517. /* 'upload_present' is used to keep a byte counter of how much data there is
  518. still left in the buffer, aimed for upload. */
  519. ssize_t upload_present;
  520. /* 'upload_fromhere' is used as a read-pointer when we uploaded parts of a
  521. buffer, so the next read should read from where this pointer points to,
  522. and the 'upload_present' contains the number of bytes available at this
  523. position */
  524. char *upload_fromhere;
  525. bool chunk; /* if set, this is a chunked transfer-encoding */
  526. bool upload_chunky; /* set TRUE if we are doing chunked transfer-encoding
  527. on upload */
  528. bool getheader; /* TRUE if header parsing is wanted */
  529. bool forbidchunk; /* used only to explicitly forbid chunk-upload for
  530. specific upload buffers. See readmoredata() in
  531. http.c for details. */
  532. void *protop; /* Allocated protocol-specific data. Each protocol
  533. handler makes sure this points to data it needs. */
  534. };
  535. /*
  536. * Specific protocol handler.
  537. */
  538. struct Curl_handler {
  539. const char *scheme; /* URL scheme name. */
  540. /* Complement to setup_connection_internals(). */
  541. CURLcode (*setup_connection)(struct connectdata *);
  542. /* These two functions MUST be set to be protocol dependent */
  543. CURLcode (*do_it)(struct connectdata *, bool *done);
  544. Curl_done_func done;
  545. /* If the curl_do() function is better made in two halves, this
  546. * curl_do_more() function will be called afterwards, if set. For example
  547. * for doing the FTP stuff after the PASV/PORT command.
  548. */
  549. Curl_do_more_func do_more;
  550. /* This function *MAY* be set to a protocol-dependent function that is run
  551. * after the connect() and everything is done, as a step in the connection.
  552. * The 'done' pointer points to a bool that should be set to TRUE if the
  553. * function completes before return. If it doesn't complete, the caller
  554. * should call the curl_connecting() function until it is.
  555. */
  556. CURLcode (*connect_it)(struct connectdata *, bool *done);
  557. /* See above. Currently only used for FTP. */
  558. CURLcode (*connecting)(struct connectdata *, bool *done);
  559. CURLcode (*doing)(struct connectdata *, bool *done);
  560. /* Called from the multi interface during the PROTOCONNECT phase, and it
  561. should then return a proper fd set */
  562. int (*proto_getsock)(struct connectdata *conn,
  563. curl_socket_t *socks,
  564. int numsocks);
  565. /* Called from the multi interface during the DOING phase, and it should
  566. then return a proper fd set */
  567. int (*doing_getsock)(struct connectdata *conn,
  568. curl_socket_t *socks,
  569. int numsocks);
  570. /* Called from the multi interface during the DO_MORE phase, and it should
  571. then return a proper fd set */
  572. int (*domore_getsock)(struct connectdata *conn,
  573. curl_socket_t *socks,
  574. int numsocks);
  575. /* Called from the multi interface during the DO_DONE, PERFORM and
  576. WAITPERFORM phases, and it should then return a proper fd set. Not setting
  577. this will make libcurl use the generic default one. */
  578. int (*perform_getsock)(const struct connectdata *conn,
  579. curl_socket_t *socks,
  580. int numsocks);
  581. /* This function *MAY* be set to a protocol-dependent function that is run
  582. * by the curl_disconnect(), as a step in the disconnection. If the handler
  583. * is called because the connection has been considered dead, dead_connection
  584. * is set to TRUE.
  585. */
  586. CURLcode (*disconnect)(struct connectdata *, bool dead_connection);
  587. /* If used, this function gets called from transfer.c:readwrite_data() to
  588. allow the protocol to do extra reads/writes */
  589. CURLcode (*readwrite)(struct Curl_easy *data, struct connectdata *conn,
  590. ssize_t *nread, bool *readmore);
  591. /* This function can perform various checks on the connection. See
  592. CONNCHECK_* for more information about the checks that can be performed,
  593. and CONNRESULT_* for the results that can be returned. */
  594. unsigned int (*connection_check)(struct connectdata *conn,
  595. unsigned int checks_to_perform);
  596. long defport; /* Default port. */
  597. unsigned int protocol; /* See CURLPROTO_* - this needs to be the single
  598. specific protocol bit */
  599. unsigned int flags; /* Extra particular characteristics, see PROTOPT_* */
  600. };
  601. #define PROTOPT_NONE 0 /* nothing extra */
  602. #define PROTOPT_SSL (1<<0) /* uses SSL */
  603. #define PROTOPT_DUAL (1<<1) /* this protocol uses two connections */
  604. #define PROTOPT_CLOSEACTION (1<<2) /* need action before socket close */
  605. /* some protocols will have to call the underlying functions without regard to
  606. what exact state the socket signals. IE even if the socket says "readable",
  607. the send function might need to be called while uploading, or vice versa.
  608. */
  609. #define PROTOPT_DIRLOCK (1<<3)
  610. #define PROTOPT_NONETWORK (1<<4) /* protocol doesn't use the network! */
  611. #define PROTOPT_NEEDSPWD (1<<5) /* needs a password, and if none is set it
  612. gets a default */
  613. #define PROTOPT_NOURLQUERY (1<<6) /* protocol can't handle
  614. url query strings (?foo=bar) ! */
  615. #define PROTOPT_CREDSPERREQUEST (1<<7) /* requires login credentials per
  616. request instead of per connection */
  617. #define PROTOPT_ALPN_NPN (1<<8) /* set ALPN and/or NPN for this */
  618. #define PROTOPT_STREAM (1<<9) /* a protocol with individual logical streams */
  619. #define PROTOPT_URLOPTIONS (1<<10) /* allow options part in the userinfo field
  620. of the URL */
  621. #define PROTOPT_PROXY_AS_HTTP (1<<11) /* allow this non-HTTP scheme over a
  622. HTTP proxy as HTTP proxies may know
  623. this protocol and act as a gateway */
  624. #define PROTOPT_WILDCARD (1<<12) /* protocol supports wildcard matching */
  625. #define CONNCHECK_NONE 0 /* No checks */
  626. #define CONNCHECK_ISDEAD (1<<0) /* Check if the connection is dead. */
  627. #define CONNRESULT_NONE 0 /* No extra information. */
  628. #define CONNRESULT_DEAD (1<<0) /* The connection is dead. */
  629. #ifdef USE_RECV_BEFORE_SEND_WORKAROUND
  630. struct postponed_data {
  631. char *buffer; /* Temporal store for received data during
  632. sending, must be freed */
  633. size_t allocated_size; /* Size of temporal store */
  634. size_t recv_size; /* Size of received data during sending */
  635. size_t recv_processed; /* Size of processed part of postponed data */
  636. #ifdef DEBUGBUILD
  637. curl_socket_t bindsock;/* Structure must be bound to specific socket,
  638. used only for DEBUGASSERT */
  639. #endif /* DEBUGBUILD */
  640. };
  641. #endif /* USE_RECV_BEFORE_SEND_WORKAROUND */
  642. struct proxy_info {
  643. struct hostname host;
  644. long port;
  645. curl_proxytype proxytype; /* what kind of proxy that is in use */
  646. char *user; /* proxy user name string, allocated */
  647. char *passwd; /* proxy password string, allocated */
  648. };
  649. #define CONNECT_BUFFER_SIZE 16384
  650. /* struct for HTTP CONNECT state data */
  651. struct http_connect_state {
  652. char connect_buffer[CONNECT_BUFFER_SIZE];
  653. int perline; /* count bytes per line */
  654. int keepon;
  655. char *line_start;
  656. char *ptr; /* where to store more data */
  657. curl_off_t cl; /* size of content to read and ignore */
  658. bool chunked_encoding;
  659. enum {
  660. TUNNEL_INIT, /* init/default/no tunnel state */
  661. TUNNEL_CONNECT, /* CONNECT has been sent off */
  662. TUNNEL_COMPLETE /* CONNECT response received completely */
  663. } tunnel_state;
  664. bool close_connection;
  665. };
  666. /*
  667. * The connectdata struct contains all fields and variables that should be
  668. * unique for an entire connection.
  669. */
  670. struct connectdata {
  671. /* 'data' is the CURRENT Curl_easy using this connection -- take great
  672. caution that this might very well vary between different times this
  673. connection is used! */
  674. struct Curl_easy *data;
  675. struct curl_llist_element bundle_node; /* conncache */
  676. /* chunk is for HTTP chunked encoding, but is in the general connectdata
  677. struct only because we can do just about any protocol through a HTTP proxy
  678. and a HTTP proxy may in fact respond using chunked encoding */
  679. struct Curl_chunker chunk;
  680. curl_closesocket_callback fclosesocket; /* function closing the socket(s) */
  681. void *closesocket_client;
  682. /* This is used by the connection cache logic. If this returns TRUE, this
  683. handle is being used by one or more easy handles and can only used by any
  684. other easy handle without careful consideration (== only for
  685. pipelining/multiplexing) and it cannot be used by another multi
  686. handle! */
  687. #define CONN_INUSE(c) ((c)->send_pipe.size + (c)->recv_pipe.size)
  688. /**** Fields set when inited and not modified again */
  689. long connection_id; /* Contains a unique number to make it easier to
  690. track the connections in the log output */
  691. /* 'dns_entry' is the particular host we use. This points to an entry in the
  692. DNS cache and it will not get pruned while locked. It gets unlocked in
  693. Curl_done(). This entry will be NULL if the connection is re-used as then
  694. there is no name resolve done. */
  695. struct Curl_dns_entry *dns_entry;
  696. /* 'ip_addr' is the particular IP we connected to. It points to a struct
  697. within the DNS cache, so this pointer is only valid as long as the DNS
  698. cache entry remains locked. It gets unlocked in Curl_done() */
  699. Curl_addrinfo *ip_addr;
  700. Curl_addrinfo *tempaddr[2]; /* for happy eyeballs */
  701. /* 'ip_addr_str' is the ip_addr data as a human readable string.
  702. It remains available as long as the connection does, which is longer than
  703. the ip_addr itself. */
  704. char ip_addr_str[MAX_IPADR_LEN];
  705. unsigned int scope_id; /* Scope id for IPv6 */
  706. int socktype; /* SOCK_STREAM or SOCK_DGRAM */
  707. struct hostname host;
  708. char *secondaryhostname; /* secondary socket host name (ftp) */
  709. struct hostname conn_to_host; /* the host to connect to. valid only if
  710. bits.conn_to_host is set */
  711. struct proxy_info socks_proxy;
  712. struct proxy_info http_proxy;
  713. long port; /* which port to use locally */
  714. int remote_port; /* the remote port, not the proxy port! */
  715. int conn_to_port; /* the remote port to connect to. valid only if
  716. bits.conn_to_port is set */
  717. unsigned short secondary_port; /* secondary socket remote port to connect to
  718. (ftp) */
  719. /* 'primary_ip' and 'primary_port' get filled with peer's numerical
  720. ip address and port number whenever an outgoing connection is
  721. *attempted* from the primary socket to a remote address. When more
  722. than one address is tried for a connection these will hold data
  723. for the last attempt. When the connection is actually established
  724. these are updated with data which comes directly from the socket. */
  725. char primary_ip[MAX_IPADR_LEN];
  726. long primary_port;
  727. /* 'local_ip' and 'local_port' get filled with local's numerical
  728. ip address and port number whenever an outgoing connection is
  729. **established** from the primary socket to a remote address. */
  730. char local_ip[MAX_IPADR_LEN];
  731. long local_port;
  732. char *user; /* user name string, allocated */
  733. char *passwd; /* password string, allocated */
  734. char *options; /* options string, allocated */
  735. char *oauth_bearer; /* bearer token for OAuth 2.0, allocated */
  736. int httpversion; /* the HTTP version*10 reported by the server */
  737. int rtspversion; /* the RTSP version*10 reported by the server */
  738. struct curltime now; /* "current" time */
  739. struct curltime created; /* creation time */
  740. curl_socket_t sock[2]; /* two sockets, the second is used for the data
  741. transfer when doing FTP */
  742. curl_socket_t tempsock[2]; /* temporary sockets for happy eyeballs */
  743. bool sock_accepted[2]; /* TRUE if the socket on this index was created with
  744. accept() */
  745. Curl_recv *recv[2];
  746. Curl_send *send[2];
  747. #ifdef USE_RECV_BEFORE_SEND_WORKAROUND
  748. struct postponed_data postponed[2]; /* two buffers for two sockets */
  749. #endif /* USE_RECV_BEFORE_SEND_WORKAROUND */
  750. struct ssl_connect_data ssl[2]; /* this is for ssl-stuff */
  751. struct ssl_connect_data proxy_ssl[2]; /* this is for proxy ssl-stuff */
  752. #ifdef USE_SSL
  753. void *ssl_extra; /* separately allocated backend-specific data */
  754. #endif
  755. struct ssl_primary_config ssl_config;
  756. struct ssl_primary_config proxy_ssl_config;
  757. bool tls_upgraded;
  758. struct ConnectBits bits; /* various state-flags for this connection */
  759. /* connecttime: when connect() is called on the current IP address. Used to
  760. be able to track when to move on to try next IP - but only when the multi
  761. interface is used. */
  762. struct curltime connecttime;
  763. /* The two fields below get set in Curl_connecthost */
  764. int num_addr; /* number of addresses to try to connect to */
  765. time_t timeoutms_per_addr; /* how long time in milliseconds to spend on
  766. trying to connect to each IP address */
  767. const struct Curl_handler *handler; /* Connection's protocol handler */
  768. const struct Curl_handler *given; /* The protocol first given */
  769. long ip_version; /* copied from the Curl_easy at creation time */
  770. /**** curl_get() phase fields */
  771. curl_socket_t sockfd; /* socket to read from or CURL_SOCKET_BAD */
  772. curl_socket_t writesockfd; /* socket to write to, it may very
  773. well be the same we read from.
  774. CURL_SOCKET_BAD disables */
  775. /** Dynamically allocated strings, MUST be freed before this **/
  776. /** struct is killed. **/
  777. struct dynamically_allocated_data {
  778. char *proxyuserpwd;
  779. char *uagent;
  780. char *accept_encoding;
  781. char *userpwd;
  782. char *rangeline;
  783. char *ref;
  784. char *host;
  785. char *cookiehost;
  786. char *rtsp_transport;
  787. char *te; /* TE: request header */
  788. } allocptr;
  789. #ifdef HAVE_GSSAPI
  790. int sec_complete; /* if Kerberos is enabled for this connection */
  791. enum protection_level command_prot;
  792. enum protection_level data_prot;
  793. enum protection_level request_data_prot;
  794. size_t buffer_size;
  795. struct krb5buffer in_buffer;
  796. void *app_data;
  797. const struct Curl_sec_client_mech *mech;
  798. struct sockaddr_in local_addr;
  799. #endif
  800. #if defined(USE_KERBEROS5) /* Consider moving some of the above GSS-API */
  801. struct kerberos5data krb5; /* variables into the structure definition, */
  802. #endif /* however, some of them are ftp specific. */
  803. /* the two following *_inuse fields are only flags, not counters in any way.
  804. If TRUE it means the channel is in use, and if FALSE it means the channel
  805. is up for grabs by one. */
  806. bool readchannel_inuse; /* whether the read channel is in use by an easy
  807. handle */
  808. bool writechannel_inuse; /* whether the write channel is in use by an easy
  809. handle */
  810. struct curl_llist send_pipe; /* List of handles waiting to send on this
  811. pipeline */
  812. struct curl_llist recv_pipe; /* List of handles waiting to read their
  813. responses on this pipeline */
  814. char *master_buffer; /* The master buffer allocated on-demand;
  815. used for pipelining. */
  816. size_t read_pos; /* Current read position in the master buffer */
  817. size_t buf_len; /* Length of the buffer?? */
  818. curl_seek_callback seek_func; /* function that seeks the input */
  819. void *seek_client; /* pointer to pass to the seek() above */
  820. /*************** Request - specific items ************/
  821. #if defined(USE_NTLM)
  822. struct ntlmdata ntlm; /* NTLM differs from other authentication schemes
  823. because it authenticates connections, not
  824. single requests! */
  825. struct ntlmdata proxyntlm; /* NTLM data for proxy */
  826. #if defined(NTLM_WB_ENABLED)
  827. /* used for communication with Samba's winbind daemon helper ntlm_auth */
  828. curl_socket_t ntlm_auth_hlpr_socket;
  829. pid_t ntlm_auth_hlpr_pid;
  830. char *challenge_header;
  831. char *response_header;
  832. #endif
  833. #endif
  834. char syserr_buf [256]; /* buffer for Curl_strerror() */
  835. #ifdef CURLRES_ASYNCH
  836. /* data used for the asynch name resolve callback */
  837. struct Curl_async async;
  838. #endif
  839. /* These three are used for chunked-encoding trailer support */
  840. char *trailer; /* allocated buffer to store trailer in */
  841. int trlMax; /* allocated buffer size */
  842. int trlPos; /* index of where to store data */
  843. union {
  844. struct ftp_conn ftpc;
  845. struct http_conn httpc;
  846. struct ssh_conn sshc;
  847. struct tftp_state_data *tftpc;
  848. struct imap_conn imapc;
  849. struct pop3_conn pop3c;
  850. struct smtp_conn smtpc;
  851. struct rtsp_conn rtspc;
  852. struct smb_conn smbc;
  853. void *generic; /* RTMP and LDAP use this */
  854. } proto;
  855. int cselect_bits; /* bitmask of socket events */
  856. int waitfor; /* current READ/WRITE bits to wait for */
  857. #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
  858. int socks5_gssapi_enctype;
  859. #endif
  860. /* When this connection is created, store the conditions for the local end
  861. bind. This is stored before the actual bind and before any connection is
  862. made and will serve the purpose of being used for comparison reasons so
  863. that subsequent bound-requested connections aren't accidentally re-using
  864. wrong connections. */
  865. char *localdev;
  866. unsigned short localport;
  867. int localportrange;
  868. struct http_connect_state *connect_state; /* for HTTP CONNECT */
  869. struct connectbundle *bundle; /* The bundle we are member of */
  870. int negnpn; /* APLN or NPN TLS negotiated protocol, CURL_HTTP_VERSION* */
  871. #ifdef USE_UNIX_SOCKETS
  872. char *unix_domain_socket;
  873. bool abstract_unix_socket;
  874. #endif
  875. };
  876. /* The end of connectdata. */
  877. /*
  878. * Struct to keep statistical and informational data.
  879. * All variables in this struct must be initialized/reset in Curl_initinfo().
  880. */
  881. struct PureInfo {
  882. int httpcode; /* Recent HTTP, FTP, RTSP or SMTP response code */
  883. int httpproxycode; /* response code from proxy when received separate */
  884. int httpversion; /* the http version number X.Y = X*10+Y */
  885. time_t filetime; /* If requested, this is might get set. Set to -1 if the
  886. time was unretrievable. */
  887. bool timecond; /* set to TRUE if the time condition didn't match, which
  888. thus made the document NOT get fetched */
  889. long header_size; /* size of read header(s) in bytes */
  890. long request_size; /* the amount of bytes sent in the request(s) */
  891. unsigned long proxyauthavail; /* what proxy auth types were announced */
  892. unsigned long httpauthavail; /* what host auth types were announced */
  893. long numconnects; /* how many new connection did libcurl created */
  894. char *contenttype; /* the content type of the object */
  895. char *wouldredirect; /* URL this would've been redirected to if asked to */
  896. /* PureInfo members 'conn_primary_ip', 'conn_primary_port', 'conn_local_ip'
  897. and, 'conn_local_port' are copied over from the connectdata struct in
  898. order to allow curl_easy_getinfo() to return this information even when
  899. the session handle is no longer associated with a connection, and also
  900. allow curl_easy_reset() to clear this information from the session handle
  901. without disturbing information which is still alive, and that might be
  902. reused, in the connection cache. */
  903. char conn_primary_ip[MAX_IPADR_LEN];
  904. long conn_primary_port;
  905. char conn_local_ip[MAX_IPADR_LEN];
  906. long conn_local_port;
  907. const char *conn_scheme;
  908. unsigned int conn_protocol;
  909. struct curl_certinfo certs; /* info about the certs, only populated in
  910. OpenSSL builds. Asked for with
  911. CURLOPT_CERTINFO / CURLINFO_CERTINFO */
  912. };
  913. struct Progress {
  914. time_t lastshow; /* time() of the last displayed progress meter or NULL to
  915. force redraw at next call */
  916. curl_off_t size_dl; /* total expected size */
  917. curl_off_t size_ul; /* total expected size */
  918. curl_off_t downloaded; /* transferred so far */
  919. curl_off_t uploaded; /* transferred so far */
  920. curl_off_t current_speed; /* uses the currently fastest transfer */
  921. bool callback; /* set when progress callback is used */
  922. int width; /* screen width at download start */
  923. int flags; /* see progress.h */
  924. time_t timespent;
  925. curl_off_t dlspeed;
  926. curl_off_t ulspeed;
  927. time_t t_nslookup;
  928. time_t t_connect;
  929. time_t t_appconnect;
  930. time_t t_pretransfer;
  931. time_t t_starttransfer;
  932. time_t t_redirect;
  933. struct curltime start;
  934. struct curltime t_startsingle;
  935. struct curltime t_startop;
  936. struct curltime t_acceptdata;
  937. bool is_t_startransfer_set;
  938. /* upload speed limit */
  939. struct curltime ul_limit_start;
  940. curl_off_t ul_limit_size;
  941. /* download speed limit */
  942. struct curltime dl_limit_start;
  943. curl_off_t dl_limit_size;
  944. #define CURR_TIME (5 + 1) /* 6 entries for 5 seconds */
  945. curl_off_t speeder[ CURR_TIME ];
  946. struct curltime speeder_time[ CURR_TIME ];
  947. int speeder_c;
  948. };
  949. typedef enum {
  950. HTTPREQ_NONE, /* first in list */
  951. HTTPREQ_GET,
  952. HTTPREQ_POST,
  953. HTTPREQ_POST_FORM, /* we make a difference internally */
  954. HTTPREQ_POST_MIME, /* we make a difference internally */
  955. HTTPREQ_PUT,
  956. HTTPREQ_HEAD,
  957. HTTPREQ_OPTIONS,
  958. HTTPREQ_CUSTOM,
  959. HTTPREQ_LAST /* last in list */
  960. } Curl_HttpReq;
  961. typedef enum {
  962. RTSPREQ_NONE, /* first in list */
  963. RTSPREQ_OPTIONS,
  964. RTSPREQ_DESCRIBE,
  965. RTSPREQ_ANNOUNCE,
  966. RTSPREQ_SETUP,
  967. RTSPREQ_PLAY,
  968. RTSPREQ_PAUSE,
  969. RTSPREQ_TEARDOWN,
  970. RTSPREQ_GET_PARAMETER,
  971. RTSPREQ_SET_PARAMETER,
  972. RTSPREQ_RECORD,
  973. RTSPREQ_RECEIVE,
  974. RTSPREQ_LAST /* last in list */
  975. } Curl_RtspReq;
  976. /*
  977. * Values that are generated, temporary or calculated internally for a
  978. * "session handle" must be defined within the 'struct UrlState'. This struct
  979. * will be used within the Curl_easy struct. When the 'Curl_easy'
  980. * struct is cloned, this data MUST NOT be copied.
  981. *
  982. * Remember that any "state" information goes globally for the curl handle.
  983. * Session-data MUST be put in the connectdata struct and here. */
  984. #define MAX_CURL_USER_LENGTH 256
  985. #define MAX_CURL_PASSWORD_LENGTH 256
  986. struct auth {
  987. unsigned long want; /* Bitmask set to the authentication methods wanted by
  988. app (with CURLOPT_HTTPAUTH or CURLOPT_PROXYAUTH). */
  989. unsigned long picked;
  990. unsigned long avail; /* Bitmask for what the server reports to support for
  991. this resource */
  992. bool done; /* TRUE when the auth phase is done and ready to do the *actual*
  993. request */
  994. bool multipass; /* TRUE if this is not yet authenticated but within the
  995. auth multipass negotiation */
  996. bool iestyle; /* TRUE if digest should be done IE-style or FALSE if it should
  997. be RFC compliant */
  998. };
  999. struct Curl_http2_dep {
  1000. struct Curl_http2_dep *next;
  1001. struct Curl_easy *data;
  1002. };
  1003. /*
  1004. * This struct is for holding data that was attempted to get sent to the user's
  1005. * callback but is held due to pausing. One instance per type (BOTH, HEADER,
  1006. * BODY).
  1007. */
  1008. struct tempbuf {
  1009. char *buf; /* allocated buffer to keep data in when a write callback
  1010. returns to make the connection paused */
  1011. size_t len; /* size of the 'tempwrite' allocated buffer */
  1012. int type; /* type of the 'tempwrite' buffer as a bitmask that is used with
  1013. Curl_client_write() */
  1014. };
  1015. /* Timers */
  1016. typedef enum {
  1017. EXPIRE_100_TIMEOUT,
  1018. EXPIRE_ASYNC_NAME,
  1019. EXPIRE_CONNECTTIMEOUT,
  1020. EXPIRE_DNS_PER_NAME,
  1021. EXPIRE_HAPPY_EYEBALLS,
  1022. EXPIRE_MULTI_PENDING,
  1023. EXPIRE_RUN_NOW,
  1024. EXPIRE_SPEEDCHECK,
  1025. EXPIRE_TIMEOUT,
  1026. EXPIRE_TOOFAST,
  1027. EXPIRE_LAST /* not an actual timer, used as a marker only */
  1028. } expire_id;
  1029. /*
  1030. * One instance for each timeout an easy handle can set.
  1031. */
  1032. struct time_node {
  1033. struct curl_llist_element list;
  1034. struct curltime time;
  1035. expire_id eid;
  1036. };
  1037. struct UrlState {
  1038. /* Points to the connection cache */
  1039. struct conncache *conn_cache;
  1040. /* when curl_easy_perform() is called, the multi handle is "owned" by
  1041. the easy handle so curl_easy_cleanup() on such an easy handle will
  1042. also close the multi handle! */
  1043. bool multi_owned_by_easy;
  1044. /* buffers to store authentication data in, as parsed from input options */
  1045. struct curltime keeps_speed; /* for the progress meter really */
  1046. struct connectdata *lastconnect; /* The last connection, NULL if undefined */
  1047. char *headerbuff; /* allocated buffer to store headers in */
  1048. size_t headersize; /* size of the allocation */
  1049. char *buffer; /* download buffer */
  1050. char *ulbuf; /* alloced upload buffer or NULL */
  1051. curl_off_t current_speed; /* the ProgressShow() function sets this,
  1052. bytes / second */
  1053. bool this_is_a_follow; /* this is a followed Location: request */
  1054. bool refused_stream; /* this was refused, try again */
  1055. char *first_host; /* host name of the first (not followed) request.
  1056. if set, this should be the host name that we will
  1057. sent authorization to, no else. Used to make Location:
  1058. following not keep sending user+password... This is
  1059. strdup() data.
  1060. */
  1061. int first_remote_port; /* remote port of the first (not followed) request */
  1062. struct curl_ssl_session *session; /* array of 'max_ssl_sessions' size */
  1063. long sessionage; /* number of the most recent session */
  1064. unsigned int tempcount; /* number of entries in use in tempwrite, 0 - 3 */
  1065. struct tempbuf tempwrite[3]; /* BOTH, HEADER, BODY */
  1066. char *scratch; /* huge buffer[set.buffer_size*2] for upload CRLF replacing */
  1067. bool errorbuf; /* Set to TRUE if the error buffer is already filled in.
  1068. This must be set to FALSE every time _easy_perform() is
  1069. called. */
  1070. int os_errno; /* filled in with errno whenever an error occurs */
  1071. #ifdef HAVE_SIGNAL
  1072. /* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */
  1073. void (*prev_signal)(int sig);
  1074. #endif
  1075. bool allow_port; /* Is set.use_port allowed to take effect or not. This
  1076. is always set TRUE when curl_easy_perform() is called. */
  1077. struct digestdata digest; /* state data for host Digest auth */
  1078. struct digestdata proxydigest; /* state data for proxy Digest auth */
  1079. #ifdef USE_SPNEGO
  1080. struct negotiatedata negotiate; /* state data for host Negotiate auth */
  1081. struct negotiatedata proxyneg; /* state data for proxy Negotiate auth */
  1082. #endif
  1083. struct auth authhost; /* auth details for host */
  1084. struct auth authproxy; /* auth details for proxy */
  1085. bool authproblem; /* TRUE if there's some problem authenticating */
  1086. void *resolver; /* resolver state, if it is used in the URL state -
  1087. ares_channel f.e. */
  1088. #if defined(USE_OPENSSL)
  1089. /* void instead of ENGINE to avoid bleeding OpenSSL into this header */
  1090. void *engine;
  1091. #endif /* USE_OPENSSL */
  1092. struct curltime expiretime; /* set this with Curl_expire() only */
  1093. struct Curl_tree timenode; /* for the splay stuff */
  1094. struct curl_llist timeoutlist; /* list of pending timeouts */
  1095. struct time_node expires[EXPIRE_LAST]; /* nodes for each expire type */
  1096. /* a place to store the most recently set FTP entrypath */
  1097. char *most_recent_ftp_entrypath;
  1098. /* set after initial USER failure, to prevent an authentication loop */
  1099. bool ftp_trying_alternative;
  1100. bool wildcardmatch; /* enable wildcard matching */
  1101. int httpversion; /* the lowest HTTP version*10 reported by any server
  1102. involved in this request */
  1103. bool expect100header; /* TRUE if we added Expect: 100-continue */
  1104. #if !defined(WIN32) && !defined(MSDOS) && !defined(__EMX__) && \
  1105. !defined(__SYMBIAN32__)
  1106. /* do FTP line-end conversions on most platforms */
  1107. #define CURL_DO_LINEEND_CONV
  1108. /* for FTP downloads: track CRLF sequences that span blocks */
  1109. bool prev_block_had_trailing_cr;
  1110. /* for FTP downloads: how many CRLFs did we converted to LFs? */
  1111. curl_off_t crlf_conversions;
  1112. #endif
  1113. char *pathbuffer;/* allocated buffer to store the URL's path part in */
  1114. char *path; /* path to use, points to somewhere within the pathbuffer
  1115. area */
  1116. bool slash_removed; /* set TRUE if the 'path' points to a path where the
  1117. initial URL slash separator has been taken off */
  1118. bool use_range;
  1119. bool rangestringalloc; /* the range string is malloc()'ed */
  1120. char *range; /* range, if used. See README for detailed specification on
  1121. this syntax. */
  1122. curl_off_t resume_from; /* continue [ftp] transfer from here */
  1123. /* This RTSP state information survives requests and connections */
  1124. long rtsp_next_client_CSeq; /* the session's next client CSeq */
  1125. long rtsp_next_server_CSeq; /* the session's next server CSeq */
  1126. long rtsp_CSeq_recv; /* most recent CSeq received */
  1127. curl_off_t infilesize; /* size of file to upload, -1 means unknown.
  1128. Copied from set.filesize at start of operation */
  1129. size_t drain; /* Increased when this stream has data to read, even if its
  1130. socket is not necessarily is readable. Decreased when
  1131. checked. */
  1132. bool done; /* set to FALSE when Curl_init_do() is called and set to TRUE
  1133. when multi_done() is called, to prevent multi_done() to get
  1134. invoked twice when the multi interface is used. */
  1135. curl_read_callback fread_func; /* read callback/function */
  1136. void *in; /* CURLOPT_READDATA */
  1137. struct Curl_easy *stream_depends_on;
  1138. bool stream_depends_e; /* set or don't set the Exclusive bit */
  1139. int stream_weight;
  1140. #ifdef CURLDEBUG
  1141. bool conncache_lock;
  1142. #endif
  1143. };
  1144. /*
  1145. * This 'DynamicStatic' struct defines dynamic states that actually change
  1146. * values in the 'UserDefined' area, which MUST be taken into consideration
  1147. * if the UserDefined struct is cloned or similar. You can probably just
  1148. * copy these, but each one indicate a special action on other data.
  1149. */
  1150. struct DynamicStatic {
  1151. char *url; /* work URL, copied from UserDefined */
  1152. bool url_alloc; /* URL string is malloc()'ed */
  1153. char *referer; /* referer string */
  1154. bool referer_alloc; /* referer string is malloc()ed */
  1155. struct curl_slist *cookielist; /* list of cookie files set by
  1156. curl_easy_setopt(COOKIEFILE) calls */
  1157. struct curl_slist *resolve; /* set to point to the set.resolve list when
  1158. this should be dealt with in pretransfer */
  1159. };
  1160. /*
  1161. * This 'UserDefined' struct must only contain data that is set once to go
  1162. * for many (perhaps) independent connections. Values that are generated or
  1163. * calculated internally for the "session handle" MUST be defined within the
  1164. * 'struct UrlState' instead. The only exceptions MUST note the changes in
  1165. * the 'DynamicStatic' struct.
  1166. * Character pointer fields point to dynamic storage, unless otherwise stated.
  1167. */
  1168. struct Curl_multi; /* declared and used only in multi.c */
  1169. enum dupstring {
  1170. STRING_CERT_ORIG, /* client certificate file name */
  1171. STRING_CERT_PROXY, /* client certificate file name */
  1172. STRING_CERT_TYPE_ORIG, /* format for certificate (default: PEM)*/
  1173. STRING_CERT_TYPE_PROXY, /* format for certificate (default: PEM)*/
  1174. STRING_COOKIE, /* HTTP cookie string to send */
  1175. STRING_COOKIEJAR, /* dump all cookies to this file */
  1176. STRING_CUSTOMREQUEST, /* HTTP/FTP/RTSP request/method to use */
  1177. STRING_DEFAULT_PROTOCOL, /* Protocol to use when the URL doesn't specify */
  1178. STRING_DEVICE, /* local network interface/address to use */
  1179. STRING_ENCODING, /* Accept-Encoding string */
  1180. STRING_FTP_ACCOUNT, /* ftp account data */
  1181. STRING_FTP_ALTERNATIVE_TO_USER, /* command to send if USER/PASS fails */
  1182. STRING_FTPPORT, /* port to send with the FTP PORT command */
  1183. STRING_KEY_ORIG, /* private key file name */
  1184. STRING_KEY_PROXY, /* private key file name */
  1185. STRING_KEY_PASSWD_ORIG, /* plain text private key password */
  1186. STRING_KEY_PASSWD_PROXY, /* plain text private key password */
  1187. STRING_KEY_TYPE_ORIG, /* format for private key (default: PEM) */
  1188. STRING_KEY_TYPE_PROXY, /* format for private key (default: PEM) */
  1189. STRING_KRB_LEVEL, /* krb security level */
  1190. STRING_NETRC_FILE, /* if not NULL, use this instead of trying to find
  1191. $HOME/.netrc */
  1192. STRING_PROXY, /* proxy to use */
  1193. STRING_PRE_PROXY, /* pre socks proxy to use */
  1194. STRING_SET_RANGE, /* range, if used */
  1195. STRING_SET_REFERER, /* custom string for the HTTP referer field */
  1196. STRING_SET_URL, /* what original URL to work on */
  1197. STRING_SSL_CAPATH_ORIG, /* CA directory name (doesn't work on windows) */
  1198. STRING_SSL_CAPATH_PROXY, /* CA directory name (doesn't work on windows) */
  1199. STRING_SSL_CAFILE_ORIG, /* certificate file to verify peer against */
  1200. STRING_SSL_CAFILE_PROXY, /* certificate file to verify peer against */
  1201. STRING_SSL_PINNEDPUBLICKEY_ORIG, /* public key file to verify peer against */
  1202. STRING_SSL_PINNEDPUBLICKEY_PROXY, /* public key file to verify proxy */
  1203. STRING_SSL_CIPHER_LIST_ORIG, /* list of ciphers to use */
  1204. STRING_SSL_CIPHER_LIST_PROXY, /* list of ciphers to use */
  1205. STRING_SSL_CIPHER13_LIST_ORIG, /* list of TLS 1.3 ciphers to use */
  1206. STRING_SSL_CIPHER13_LIST_PROXY, /* list of TLS 1.3 ciphers to use */
  1207. STRING_SSL_EGDSOCKET, /* path to file containing the EGD daemon socket */
  1208. STRING_SSL_RANDOM_FILE, /* path to file containing "random" data */
  1209. STRING_USERAGENT, /* User-Agent string */
  1210. STRING_SSL_CRLFILE_ORIG, /* crl file to check certificate */
  1211. STRING_SSL_CRLFILE_PROXY, /* crl file to check certificate */
  1212. STRING_SSL_ISSUERCERT_ORIG, /* issuer cert file to check certificate */
  1213. STRING_SSL_ISSUERCERT_PROXY, /* issuer cert file to check certificate */
  1214. STRING_SSL_ENGINE, /* name of ssl engine */
  1215. STRING_USERNAME, /* <username>, if used */
  1216. STRING_PASSWORD, /* <password>, if used */
  1217. STRING_OPTIONS, /* <options>, if used */
  1218. STRING_PROXYUSERNAME, /* Proxy <username>, if used */
  1219. STRING_PROXYPASSWORD, /* Proxy <password>, if used */
  1220. STRING_NOPROXY, /* List of hosts which should not use the proxy, if
  1221. used */
  1222. STRING_RTSP_SESSION_ID, /* Session ID to use */
  1223. STRING_RTSP_STREAM_URI, /* Stream URI for this request */
  1224. STRING_RTSP_TRANSPORT, /* Transport for this session */
  1225. #if defined(USE_LIBSSH2) || defined(USE_LIBSSH)
  1226. STRING_SSH_PRIVATE_KEY, /* path to the private key file for auth */
  1227. STRING_SSH_PUBLIC_KEY, /* path to the public key file for auth */
  1228. STRING_SSH_HOST_PUBLIC_KEY_MD5, /* md5 of host public key in ascii hex */
  1229. STRING_SSH_KNOWNHOSTS, /* file name of knownhosts file */
  1230. #endif
  1231. STRING_PROXY_SERVICE_NAME, /* Proxy service name */
  1232. STRING_SERVICE_NAME, /* Service name */
  1233. STRING_MAIL_FROM,
  1234. STRING_MAIL_AUTH,
  1235. #ifdef USE_TLS_SRP
  1236. STRING_TLSAUTH_USERNAME_ORIG, /* TLS auth <username> */
  1237. STRING_TLSAUTH_USERNAME_PROXY, /* TLS auth <username> */
  1238. STRING_TLSAUTH_PASSWORD_ORIG, /* TLS auth <password> */
  1239. STRING_TLSAUTH_PASSWORD_PROXY, /* TLS auth <password> */
  1240. #endif
  1241. STRING_BEARER, /* <bearer>, if used */
  1242. #ifdef USE_UNIX_SOCKETS
  1243. STRING_UNIX_SOCKET_PATH, /* path to Unix socket, if used */
  1244. #endif
  1245. STRING_TARGET, /* CURLOPT_REQUEST_TARGET */
  1246. /* -- end of zero-terminated strings -- */
  1247. STRING_LASTZEROTERMINATED,
  1248. /* -- below this are pointers to binary data that cannot be strdup'ed.
  1249. Each such pointer must be added manually to Curl_dupset() --- */
  1250. STRING_COPYPOSTFIELDS, /* if POST, set the fields' values here */
  1251. STRING_LAST /* not used, just an end-of-list marker */
  1252. };
  1253. struct UserDefined {
  1254. FILE *err; /* the stderr user data goes here */
  1255. void *debugdata; /* the data that will be passed to fdebug */
  1256. char *errorbuffer; /* (Static) store failure messages in here */
  1257. long proxyport; /* If non-zero, use this port number by default. If the
  1258. proxy string features a ":[port]" that one will override
  1259. this. */
  1260. void *out; /* CURLOPT_WRITEDATA */
  1261. void *in_set; /* CURLOPT_READDATA */
  1262. void *writeheader; /* write the header to this if non-NULL */
  1263. void *rtp_out; /* write RTP to this if non-NULL */
  1264. long use_port; /* which port to use (when not using default) */
  1265. unsigned long httpauth; /* kind of HTTP authentication to use (bitmask) */
  1266. unsigned long proxyauth; /* kind of proxy authentication to use (bitmask) */
  1267. unsigned long socks5auth;/* kind of SOCKS5 authentication to use (bitmask) */
  1268. long followlocation; /* as in HTTP Location: */
  1269. long maxredirs; /* maximum no. of http(s) redirects to follow, set to -1
  1270. for infinity */
  1271. int keep_post; /* keep POSTs as POSTs after a 30x request; each
  1272. bit represents a request, from 301 to 303 */
  1273. bool free_referer; /* set TRUE if 'referer' points to a string we
  1274. allocated */
  1275. void *postfields; /* if POST, set the fields' values here */
  1276. curl_seek_callback seek_func; /* function that seeks the input */
  1277. curl_off_t postfieldsize; /* if POST, this might have a size to use instead
  1278. of strlen(), and then the data *may* be binary
  1279. (contain zero bytes) */
  1280. unsigned short localport; /* local port number to bind to */
  1281. int localportrange; /* number of additional port numbers to test in case the
  1282. 'localport' one can't be bind()ed */
  1283. curl_write_callback fwrite_func; /* function that stores the output */
  1284. curl_write_callback fwrite_header; /* function that stores headers */
  1285. curl_write_callback fwrite_rtp; /* function that stores interleaved RTP */
  1286. curl_read_callback fread_func_set; /* function that reads the input */
  1287. int is_fread_set; /* boolean, has read callback been set to non-NULL? */
  1288. int is_fwrite_set; /* boolean, has write callback been set to non-NULL? */
  1289. curl_progress_callback fprogress; /* OLD and deprecated progress callback */
  1290. curl_xferinfo_callback fxferinfo; /* progress callback */
  1291. curl_debug_callback fdebug; /* function that write informational data */
  1292. curl_ioctl_callback ioctl_func; /* function for I/O control */
  1293. curl_sockopt_callback fsockopt; /* function for setting socket options */
  1294. void *sockopt_client; /* pointer to pass to the socket options callback */
  1295. curl_opensocket_callback fopensocket; /* function for checking/translating
  1296. the address and opening the
  1297. socket */
  1298. void *opensocket_client;
  1299. curl_closesocket_callback fclosesocket; /* function for closing the
  1300. socket */
  1301. void *closesocket_client;
  1302. void *seek_client; /* pointer to pass to the seek callback */
  1303. /* the 3 curl_conv_callback functions below are used on non-ASCII hosts */
  1304. /* function to convert from the network encoding: */
  1305. curl_conv_callback convfromnetwork;
  1306. /* function to convert to the network encoding: */
  1307. curl_conv_callback convtonetwork;
  1308. /* function to convert from UTF-8 encoding: */
  1309. curl_conv_callback convfromutf8;
  1310. void *progress_client; /* pointer to pass to the progress callback */
  1311. void *ioctl_client; /* pointer to pass to the ioctl callback */
  1312. long timeout; /* in milliseconds, 0 means no timeout */
  1313. long connecttimeout; /* in milliseconds, 0 means no timeout */
  1314. long accepttimeout; /* in milliseconds, 0 means no timeout */
  1315. long happy_eyeballs_timeout; /* in milliseconds, 0 is a valid value */
  1316. long server_response_timeout; /* in milliseconds, 0 means no timeout */
  1317. long tftp_blksize; /* in bytes, 0 means use default */
  1318. bool tftp_no_options; /* do not send TFTP options requests */
  1319. curl_off_t filesize; /* size of file to upload, -1 means unknown */
  1320. long low_speed_limit; /* bytes/second */
  1321. long low_speed_time; /* number of seconds */
  1322. curl_off_t max_send_speed; /* high speed limit in bytes/second for upload */
  1323. curl_off_t max_recv_speed; /* high speed limit in bytes/second for
  1324. download */
  1325. curl_off_t set_resume_from; /* continue [ftp] transfer from here */
  1326. struct curl_slist *headers; /* linked list of extra headers */
  1327. struct curl_slist *proxyheaders; /* linked list of extra CONNECT headers */
  1328. struct curl_httppost *httppost; /* linked list of old POST data */
  1329. curl_mimepart mimepost; /* MIME/POST data. */
  1330. bool sep_headers; /* handle host and proxy headers separately */
  1331. bool cookiesession; /* new cookie session? */
  1332. bool crlf; /* convert crlf on ftp upload(?) */
  1333. struct curl_slist *quote; /* after connection is established */
  1334. struct curl_slist *postquote; /* after the transfer */
  1335. struct curl_slist *prequote; /* before the transfer, after type */
  1336. struct curl_slist *source_quote; /* 3rd party quote */
  1337. struct curl_slist *source_prequote; /* in 3rd party transfer mode - before
  1338. the transfer on source host */
  1339. struct curl_slist *source_postquote; /* in 3rd party transfer mode - after
  1340. the transfer on source host */
  1341. struct curl_slist *telnet_options; /* linked list of telnet options */
  1342. struct curl_slist *resolve; /* list of names to add/remove from
  1343. DNS cache */
  1344. struct curl_slist *connect_to; /* list of host:port mappings to override
  1345. the hostname and port to connect to */
  1346. curl_TimeCond timecondition; /* kind of time/date comparison */
  1347. time_t timevalue; /* what time to compare with */
  1348. Curl_HttpReq httpreq; /* what kind of HTTP request (if any) is this */
  1349. long httpversion; /* when non-zero, a specific HTTP version requested to
  1350. be used in the library's request(s) */
  1351. bool strip_path_slash; /* strip off initial slash from path */
  1352. struct ssl_config_data ssl; /* user defined SSL stuff */
  1353. struct ssl_config_data proxy_ssl; /* user defined SSL stuff for proxy */
  1354. struct ssl_general_config general_ssl; /* general user defined SSL stuff */
  1355. curl_proxytype proxytype; /* what kind of proxy that is in use */
  1356. long dns_cache_timeout; /* DNS cache timeout */
  1357. long buffer_size; /* size of receive buffer to use */
  1358. long upload_buffer_size; /* size of upload buffer to use,
  1359. keep it >= CURL_MAX_WRITE_SIZE */
  1360. void *private_data; /* application-private data */
  1361. struct curl_slist *http200aliases; /* linked list of aliases for http200 */
  1362. long ipver; /* the CURL_IPRESOLVE_* defines in the public header file
  1363. 0 - whatever, 1 - v2, 2 - v6 */
  1364. curl_off_t max_filesize; /* Maximum file size to download */
  1365. curl_ftpfile ftp_filemethod; /* how to get to a file when FTP is used */
  1366. int ftp_create_missing_dirs; /* 1 - create directories that don't exist
  1367. 2 - the same but also allow MKD to fail once
  1368. */
  1369. curl_sshkeycallback ssh_keyfunc; /* key matching callback */
  1370. void *ssh_keyfunc_userp; /* custom pointer to callback */
  1371. bool ssh_compression; /* enable SSH compression */
  1372. /* Here follows boolean settings that define how to behave during
  1373. this session. They are STATIC, set by libcurl users or at least initially
  1374. and they don't change during operations. */
  1375. bool get_filetime; /* get the time and get of the remote file */
  1376. bool tunnel_thru_httpproxy; /* use CONNECT through a HTTP proxy */
  1377. bool prefer_ascii; /* ASCII rather than binary */
  1378. bool ftp_append; /* append, not overwrite, on upload */
  1379. bool ftp_list_only; /* switch FTP command for listing directories */
  1380. bool ftp_use_port; /* use the FTP PORT command */
  1381. bool hide_progress; /* don't use the progress meter */
  1382. bool http_fail_on_error; /* fail on HTTP error codes >= 400 */
  1383. bool http_keep_sending_on_error; /* for HTTP status codes >= 300 */
  1384. bool http_follow_location; /* follow HTTP redirects */
  1385. bool http_transfer_encoding; /* request compressed HTTP transfer-encoding */
  1386. bool allow_auth_to_other_hosts;
  1387. bool include_header; /* include received protocol headers in data output */
  1388. bool http_set_referer; /* is a custom referer used */
  1389. bool http_auto_referer; /* set "correct" referer when following location: */
  1390. bool opt_no_body; /* as set with CURLOPT_NOBODY */
  1391. bool upload; /* upload request */
  1392. enum CURL_NETRC_OPTION
  1393. use_netrc; /* defined in include/curl.h */
  1394. bool verbose; /* output verbosity */
  1395. bool krb; /* Kerberos connection requested */
  1396. bool reuse_forbid; /* forbidden to be reused, close after use */
  1397. bool reuse_fresh; /* do not re-use an existing connection */
  1398. bool ftp_use_epsv; /* if EPSV is to be attempted or not */
  1399. bool ftp_use_eprt; /* if EPRT is to be attempted or not */
  1400. bool ftp_use_pret; /* if PRET is to be used before PASV or not */
  1401. curl_usessl use_ssl; /* if AUTH TLS is to be attempted etc, for FTP or
  1402. IMAP or POP3 or others! */
  1403. curl_ftpauth ftpsslauth; /* what AUTH XXX to be attempted */
  1404. curl_ftpccc ftp_ccc; /* FTP CCC options */
  1405. bool no_signal; /* do not use any signal/alarm handler */
  1406. bool global_dns_cache; /* subject for future removal */
  1407. bool tcp_nodelay; /* whether to enable TCP_NODELAY or not */
  1408. bool ignorecl; /* ignore content length */
  1409. bool ftp_skip_ip; /* skip the IP address the FTP server passes on to
  1410. us */
  1411. bool connect_only; /* make connection, let application use the socket */
  1412. long ssh_auth_types; /* allowed SSH auth types */
  1413. bool http_te_skip; /* pass the raw body data to the user, even when
  1414. transfer-encoded (chunked, compressed) */
  1415. bool http_ce_skip; /* pass the raw body data to the user, even when
  1416. content-encoded (chunked, compressed) */
  1417. long new_file_perms; /* Permissions to use when creating remote files */
  1418. long new_directory_perms; /* Permissions to use when creating remote dirs */
  1419. bool proxy_transfer_mode; /* set transfer mode (;type=<a|i>) when doing FTP
  1420. via an HTTP proxy */
  1421. char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */
  1422. unsigned int scope_id; /* Scope id for IPv6 */
  1423. long allowed_protocols;
  1424. long redir_protocols;
  1425. #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
  1426. bool socks5_gssapi_nec; /* Flag to support NEC SOCKS5 server */
  1427. #endif
  1428. struct curl_slist *mail_rcpt; /* linked list of mail recipients */
  1429. bool sasl_ir; /* Enable/disable SASL initial response */
  1430. /* Common RTSP header options */
  1431. Curl_RtspReq rtspreq; /* RTSP request type */
  1432. long rtspversion; /* like httpversion, for RTSP */
  1433. bool wildcard_enabled; /* enable wildcard matching */
  1434. curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer
  1435. starts */
  1436. curl_chunk_end_callback chunk_end; /* called after part transferring
  1437. stopped */
  1438. curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds
  1439. to pattern (e.g. if WILDCARDMATCH is on) */
  1440. void *fnmatch_data;
  1441. long gssapi_delegation; /* GSS-API credential delegation, see the
  1442. documentation of CURLOPT_GSSAPI_DELEGATION */
  1443. bool tcp_keepalive; /* use TCP keepalives */
  1444. long tcp_keepidle; /* seconds in idle before sending keepalive probe */
  1445. long tcp_keepintvl; /* seconds between TCP keepalive probes */
  1446. bool tcp_fastopen; /* use TCP Fast Open */
  1447. size_t maxconnects; /* Max idle connections in the connection cache */
  1448. bool ssl_enable_npn; /* TLS NPN extension? */
  1449. bool ssl_enable_alpn; /* TLS ALPN extension? */
  1450. bool path_as_is; /* allow dotdots? */
  1451. bool pipewait; /* wait for pipe/multiplex status before starting a
  1452. new connection */
  1453. long expect_100_timeout; /* in milliseconds */
  1454. bool suppress_connect_headers; /* suppress proxy CONNECT response headers
  1455. from user callbacks */
  1456. bool dns_shuffle_addresses; /* whether to shuffle addresses before use */
  1457. struct Curl_easy *stream_depends_on;
  1458. bool stream_depends_e; /* set or don't set the Exclusive bit */
  1459. int stream_weight;
  1460. bool haproxyprotocol; /* whether to send HAProxy PROXY protocol v1 header */
  1461. struct Curl_http2_dep *stream_dependents;
  1462. bool abstract_unix_socket;
  1463. curl_resolver_start_callback resolver_start; /* optional callback called
  1464. before resolver start */
  1465. void *resolver_start_client; /* pointer to pass to resolver start callback */
  1466. bool disallow_username_in_url; /* disallow username in url */
  1467. };
  1468. struct Names {
  1469. struct curl_hash *hostcache;
  1470. enum {
  1471. HCACHE_NONE, /* not pointing to anything */
  1472. HCACHE_GLOBAL, /* points to the (shrug) global one */
  1473. HCACHE_MULTI, /* points to a shared one in the multi handle */
  1474. HCACHE_SHARED /* points to a shared one in a shared object */
  1475. } hostcachetype;
  1476. };
  1477. /*
  1478. * The 'connectdata' struct MUST have all the connection oriented stuff as we
  1479. * may have several simultaneous connections and connection structs in memory.
  1480. *
  1481. * The 'struct UserDefined' must only contain data that is set once to go for
  1482. * many (perhaps) independent connections. Values that are generated or
  1483. * calculated internally for the "session handle" must be defined within the
  1484. * 'struct UrlState' instead.
  1485. */
  1486. struct Curl_easy {
  1487. /* first, two fields for the linked list of these */
  1488. struct Curl_easy *next;
  1489. struct Curl_easy *prev;
  1490. struct connectdata *easy_conn; /* the "unit's" connection */
  1491. struct curl_llist_element connect_queue;
  1492. struct curl_llist_element pipeline_queue;
  1493. CURLMstate mstate; /* the handle's state */
  1494. CURLcode result; /* previous result */
  1495. struct Curl_message msg; /* A single posted message. */
  1496. /* Array with the plain socket numbers this handle takes care of, in no
  1497. particular order. Note that all sockets are added to the sockhash, where
  1498. the state etc are also kept. This array is mostly used to detect when a
  1499. socket is to be removed from the hash. See singlesocket(). */
  1500. curl_socket_t sockets[MAX_SOCKSPEREASYHANDLE];
  1501. int numsocks;
  1502. struct Names dns;
  1503. struct Curl_multi *multi; /* if non-NULL, points to the multi handle
  1504. struct to which this "belongs" when used by
  1505. the multi interface */
  1506. struct Curl_multi *multi_easy; /* if non-NULL, points to the multi handle
  1507. struct to which this "belongs" when used
  1508. by the easy interface */
  1509. struct Curl_share *share; /* Share, handles global variable mutexing */
  1510. #ifdef USE_LIBPSL
  1511. struct PslCache *psl; /* The associated PSL cache. */
  1512. #endif
  1513. struct SingleRequest req; /* Request-specific data */
  1514. struct UserDefined set; /* values set by the libcurl user */
  1515. struct DynamicStatic change; /* possibly modified userdefined data */
  1516. struct CookieInfo *cookies; /* the cookies, read from files and servers.
  1517. NOTE that the 'cookie' field in the
  1518. UserDefined struct defines if the "engine"
  1519. is to be used or not. */
  1520. struct Progress progress; /* for all the progress meter data */
  1521. struct UrlState state; /* struct for fields used for state info and
  1522. other dynamic purposes */
  1523. struct WildcardData wildcard; /* wildcard download state info */
  1524. struct PureInfo info; /* stats, reports and info data */
  1525. struct curl_tlssessioninfo tsi; /* Information about the TLS session, only
  1526. valid after a client has asked for it */
  1527. #if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
  1528. iconv_t outbound_cd; /* for translating to the network encoding */
  1529. iconv_t inbound_cd; /* for translating from the network encoding */
  1530. iconv_t utf8_cd; /* for translating to UTF8 */
  1531. #endif /* CURL_DOES_CONVERSIONS && HAVE_ICONV */
  1532. unsigned int magic; /* set to a CURLEASY_MAGIC_NUMBER */
  1533. };
  1534. #define LIBCURL_NAME "libcurl"
  1535. #endif /* HEADER_CURL_URLDATA_H */