urldata.h 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708
  1. #ifndef HEADER_CURL_URLDATA_H
  2. #define HEADER_CURL_URLDATA_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) Daniel Stenberg, <[email protected]>, 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.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. * SPDX-License-Identifier: curl
  24. *
  25. ***************************************************************************/
  26. /* This file is for lib internal stuff */
  27. #include "curl_setup.h"
  28. #define PORT_FTP 21
  29. #define PORT_FTPS 990
  30. #define PORT_TELNET 23
  31. #define PORT_HTTP 80
  32. #define PORT_HTTPS 443
  33. #define PORT_DICT 2628
  34. #define PORT_LDAP 389
  35. #define PORT_LDAPS 636
  36. #define PORT_TFTP 69
  37. #define PORT_SSH 22
  38. #define PORT_IMAP 143
  39. #define PORT_IMAPS 993
  40. #define PORT_POP3 110
  41. #define PORT_POP3S 995
  42. #define PORT_SMB 445
  43. #define PORT_SMBS 445
  44. #define PORT_SMTP 25
  45. #define PORT_SMTPS 465 /* sometimes called SSMTP */
  46. #define PORT_RTSP 554
  47. #define PORT_RTMP 1935
  48. #define PORT_RTMPT PORT_HTTP
  49. #define PORT_RTMPS PORT_HTTPS
  50. #define PORT_GOPHER 70
  51. #define PORT_MQTT 1883
  52. struct curl_trc_featt;
  53. #ifdef USE_ECH
  54. /* CURLECH_ bits for the tls_ech option */
  55. # define CURLECH_DISABLE (1<<0)
  56. # define CURLECH_GREASE (1<<1)
  57. # define CURLECH_ENABLE (1<<2)
  58. # define CURLECH_HARD (1<<3)
  59. # define CURLECH_CLA_CFG (1<<4)
  60. #endif
  61. #ifndef CURL_DISABLE_WEBSOCKETS
  62. /* CURLPROTO_GOPHERS (29) is the highest publicly used protocol bit number,
  63. * the rest are internal information. If we use higher bits we only do this on
  64. * platforms that have a >= 64-bit type and then we use such a type for the
  65. * protocol fields in the protocol handler.
  66. */
  67. #define CURLPROTO_WS (1L<<30)
  68. #define CURLPROTO_WSS ((curl_prot_t)1<<31)
  69. #else
  70. #define CURLPROTO_WS 0L
  71. #define CURLPROTO_WSS 0L
  72. #endif
  73. /* the default protocols accepting a redirect to */
  74. #define CURLPROTO_REDIR (CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_FTP | \
  75. CURLPROTO_FTPS)
  76. /* This should be undefined once we need bit 32 or higher */
  77. #define PROTO_TYPE_SMALL
  78. #ifndef PROTO_TYPE_SMALL
  79. typedef curl_off_t curl_prot_t;
  80. #else
  81. typedef unsigned int curl_prot_t;
  82. #endif
  83. /* This mask is for all the old protocols that are provided and defined in the
  84. public header and shall exclude protocols added since which are not exposed
  85. in the API */
  86. #define CURLPROTO_MASK (0x3ffffff)
  87. #define CURL_DEFAULT_USER "anonymous"
  88. #define CURL_DEFAULT_PASSWORD "[email protected]"
  89. #if !defined(_WIN32) && !defined(MSDOS)
  90. /* do FTP line-end CRLF => LF conversions on platforms that prefer LF-only. It
  91. also means: keep CRLF line endings on the CRLF platforms */
  92. #define CURL_PREFER_LF_LINEENDS
  93. #endif
  94. /* Convenience defines for checking protocols or their SSL based version. Each
  95. protocol handler should only ever have a single CURLPROTO_ in its protocol
  96. field. */
  97. #define PROTO_FAMILY_HTTP (CURLPROTO_HTTP|CURLPROTO_HTTPS|CURLPROTO_WS| \
  98. CURLPROTO_WSS)
  99. #define PROTO_FAMILY_FTP (CURLPROTO_FTP|CURLPROTO_FTPS)
  100. #define PROTO_FAMILY_POP3 (CURLPROTO_POP3|CURLPROTO_POP3S)
  101. #define PROTO_FAMILY_SMB (CURLPROTO_SMB|CURLPROTO_SMBS)
  102. #define PROTO_FAMILY_SMTP (CURLPROTO_SMTP|CURLPROTO_SMTPS)
  103. #define PROTO_FAMILY_SSH (CURLPROTO_SCP|CURLPROTO_SFTP)
  104. #if !defined(CURL_DISABLE_FTP) || defined(USE_SSH) || \
  105. !defined(CURL_DISABLE_POP3)
  106. /* these protocols support CURLOPT_DIRLISTONLY */
  107. #define CURL_LIST_ONLY_PROTOCOL 1
  108. #endif
  109. #define DEFAULT_CONNCACHE_SIZE 5
  110. /* length of longest IPv6 address string including the trailing null */
  111. #define MAX_IPADR_LEN sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")
  112. /* Default FTP/IMAP etc response timeout in milliseconds */
  113. #define RESP_TIMEOUT (60*1000)
  114. /* Max string input length is a precaution against abuse and to detect junk
  115. input easier and better. */
  116. #define CURL_MAX_INPUT_LENGTH 8000000
  117. #include "cookie.h"
  118. #include "psl.h"
  119. #include "formdata.h"
  120. #ifdef HAVE_NETINET_IN_H
  121. #include <netinet/in.h>
  122. #endif
  123. #ifdef HAVE_NETINET_IN6_H
  124. #include <netinet/in6.h>
  125. #endif
  126. #include "curlx/timeval.h"
  127. #include <curl/curl.h>
  128. #include "http_chunks.h" /* for the structs and enum stuff */
  129. #include "hostip.h"
  130. #include "hash.h"
  131. #include "splay.h"
  132. #include "curlx/dynbuf.h"
  133. #include "dynhds.h"
  134. #include "request.h"
  135. #include "netrc.h"
  136. /* On error return, the value of `pnwritten` has no meaning */
  137. typedef CURLcode (Curl_send)(struct Curl_easy *data, /* transfer */
  138. int sockindex, /* socketindex */
  139. const void *buf, /* data to write */
  140. size_t len, /* amount to send */
  141. bool eos, /* last chunk */
  142. size_t *pnwritten); /* how much sent */
  143. /* On error return, the value of `pnread` has no meaning */
  144. typedef CURLcode (Curl_recv)(struct Curl_easy *data, /* transfer */
  145. int sockindex, /* socketindex */
  146. char *buf, /* store data here */
  147. size_t len, /* max amount to read */
  148. size_t *pnread); /* how much received */
  149. #include "mime.h"
  150. #include "imap.h"
  151. #include "smtp.h"
  152. #include "ftp.h"
  153. #include "file.h"
  154. #include "vssh/ssh.h"
  155. #include "http.h"
  156. #include "rtsp.h"
  157. #include "smb.h"
  158. #include "mqtt.h"
  159. #include "ftplistparser.h"
  160. #include "multihandle.h"
  161. #include "cf-socket.h"
  162. #ifdef HAVE_GSSAPI
  163. # ifdef HAVE_GSSGNU
  164. # include <gss.h>
  165. # else
  166. # include <gssapi/gssapi.h>
  167. # endif
  168. #endif
  169. #ifdef USE_LIBSSH2
  170. #include <libssh2.h>
  171. #include <libssh2_sftp.h>
  172. #endif /* USE_LIBSSH2 */
  173. #define READBUFFER_SIZE CURL_MAX_WRITE_SIZE
  174. #define READBUFFER_MAX CURL_MAX_READ_SIZE
  175. #define READBUFFER_MIN 1024
  176. /* The default upload buffer size, should not be smaller than
  177. CURL_MAX_WRITE_SIZE, as it needs to hold a full buffer as could be sent in
  178. a write callback.
  179. The size was 16KB for many years but was bumped to 64KB because it makes
  180. libcurl able to do significantly faster uploads in some circumstances. Even
  181. larger buffers can help further, but this is deemed a fair memory/speed
  182. compromise. */
  183. #define UPLOADBUFFER_DEFAULT 65536
  184. #define UPLOADBUFFER_MAX (2*1024*1024)
  185. #define UPLOADBUFFER_MIN CURL_MAX_WRITE_SIZE
  186. #define CURLEASY_MAGIC_NUMBER 0xc0dedbadU
  187. #ifdef DEBUGBUILD
  188. /* On a debug build, we want to fail hard on easy handles that
  189. * are not NULL, but no longer have the MAGIC touch. This gives
  190. * us early warning on things only discovered by valgrind otherwise. */
  191. #define GOOD_EASY_HANDLE(x) \
  192. (((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER))? TRUE: \
  193. (DEBUGASSERT(!(x)), FALSE))
  194. #else
  195. #define GOOD_EASY_HANDLE(x) \
  196. ((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER))
  197. #endif
  198. /* SSL backend-specific data; declared differently by each SSL backend */
  199. struct ssl_backend_data;
  200. struct Curl_ssl_scache_entry;
  201. struct ssl_primary_config {
  202. char *CApath; /* certificate dir (does not work on Windows) */
  203. char *CAfile; /* certificate to verify peer against */
  204. char *issuercert; /* optional issuer certificate filename */
  205. char *clientcert;
  206. char *cipher_list; /* list of ciphers to use */
  207. char *cipher_list13; /* list of TLS 1.3 cipher suites to use */
  208. char *signature_algorithms; /* list of signature algorithms to use */
  209. char *pinned_key;
  210. char *CRLfile; /* CRL to check certificate revocation */
  211. struct curl_blob *cert_blob;
  212. struct curl_blob *ca_info_blob;
  213. struct curl_blob *issuercert_blob;
  214. #ifdef USE_TLS_SRP
  215. char *username; /* TLS username (for, e.g., SRP) */
  216. char *password; /* TLS password (for, e.g., SRP) */
  217. #endif
  218. char *curves; /* list of curves to use */
  219. unsigned int version_max; /* max supported version the client wants to use */
  220. unsigned char ssl_options; /* the CURLOPT_SSL_OPTIONS bitmask */
  221. unsigned char version; /* what version the client wants to use */
  222. BIT(verifypeer); /* set TRUE if this is desired */
  223. BIT(verifyhost); /* set TRUE if CN/SAN must match hostname */
  224. BIT(verifystatus); /* set TRUE if certificate status must be checked */
  225. BIT(cache_session); /* cache session or not */
  226. };
  227. struct ssl_config_data {
  228. struct ssl_primary_config primary;
  229. long certverifyresult; /* result from the certificate verification */
  230. curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
  231. void *fsslctxp; /* parameter for call back */
  232. char *cert_type; /* format for certificate (default: PEM)*/
  233. char *key; /* private key filename */
  234. struct curl_blob *key_blob;
  235. char *key_type; /* format for private key (default: PEM) */
  236. char *key_passwd; /* plain text private key password */
  237. BIT(certinfo); /* gather lots of certificate info */
  238. BIT(earlydata); /* use tls1.3 early data */
  239. BIT(enable_beast); /* allow this flaw for interoperability's sake */
  240. BIT(no_revoke); /* disable SSL certificate revocation checks */
  241. BIT(no_partialchain); /* do not accept partial certificate chains */
  242. BIT(revoke_best_effort); /* ignore SSL revocation offline/missing revocation
  243. list errors */
  244. BIT(native_ca_store); /* use the native ca store of operating system */
  245. BIT(auto_client_cert); /* automatically locate and use a client
  246. certificate for authentication (Schannel) */
  247. BIT(custom_cafile); /* application has set custom CA file */
  248. BIT(custom_capath); /* application has set custom CA path */
  249. BIT(custom_cablob); /* application has set custom CA blob */
  250. };
  251. struct ssl_general_config {
  252. int ca_cache_timeout; /* Certificate store cache timeout (seconds) */
  253. };
  254. #ifdef USE_WINDOWS_SSPI
  255. #include "curl_sspi.h"
  256. #endif
  257. #ifndef CURL_DISABLE_DIGEST_AUTH
  258. /* Struct used for Digest challenge-response authentication */
  259. struct digestdata {
  260. #ifdef USE_WINDOWS_SSPI
  261. BYTE *input_token;
  262. size_t input_token_len;
  263. CtxtHandle *http_context;
  264. /* copy of user/passwd used to make the identity for http_context.
  265. either may be NULL. */
  266. char *user;
  267. char *passwd;
  268. #else
  269. char *nonce;
  270. char *cnonce;
  271. char *realm;
  272. char *opaque;
  273. char *qop;
  274. char *algorithm;
  275. int nc; /* nonce count */
  276. unsigned char algo;
  277. BIT(stale); /* set true for re-negotiation */
  278. BIT(userhash);
  279. #endif
  280. };
  281. #endif
  282. typedef enum {
  283. NTLMSTATE_NONE,
  284. NTLMSTATE_TYPE1,
  285. NTLMSTATE_TYPE2,
  286. NTLMSTATE_TYPE3,
  287. NTLMSTATE_LAST
  288. } curlntlm;
  289. typedef enum {
  290. GSS_AUTHNONE,
  291. GSS_AUTHRECV,
  292. GSS_AUTHSENT,
  293. GSS_AUTHDONE,
  294. GSS_AUTHSUCC
  295. } curlnegotiate;
  296. #ifdef CURL_DISABLE_PROXY
  297. #define CONN_IS_PROXIED(x) 0
  298. #else
  299. #define CONN_IS_PROXIED(x) x->bits.proxy
  300. #endif
  301. /*
  302. * Boolean values that concerns this connection.
  303. */
  304. struct ConnectBits {
  305. #ifndef CURL_DISABLE_PROXY
  306. BIT(httpproxy); /* if set, this transfer is done through an HTTP proxy */
  307. BIT(socksproxy); /* if set, this transfer is done through a socks proxy */
  308. BIT(proxy_user_passwd); /* user+password for the proxy? */
  309. BIT(tunnel_proxy); /* if CONNECT is used to "tunnel" through the proxy.
  310. This is implicit when SSL-protocols are used through
  311. proxies, but can also be enabled explicitly by
  312. apps */
  313. BIT(proxy); /* if set, this transfer is done through a proxy - any type */
  314. #endif
  315. /* always modify bits.close with the connclose() and connkeep() macros! */
  316. BIT(close); /* if set, we close the connection after this request */
  317. BIT(reuse); /* if set, this is a reused connection */
  318. BIT(altused); /* this is an alt-svc "redirect" */
  319. BIT(conn_to_host); /* if set, this connection has a "connect to host"
  320. that overrides the host in the URL */
  321. BIT(conn_to_port); /* if set, this connection has a "connect to port"
  322. that overrides the port in the URL (remote port) */
  323. BIT(ipv6_ip); /* we communicate with a remote site specified with pure IPv6
  324. IP address */
  325. BIT(ipv6); /* we communicate with a site using an IPv6 address */
  326. BIT(do_more); /* this is set TRUE if the ->curl_do_more() function is
  327. supposed to be called, after ->curl_do() */
  328. BIT(protoconnstart);/* the protocol layer has STARTED its operation after
  329. the TCP layer connect */
  330. BIT(retry); /* this connection is about to get closed and then
  331. re-attempted at another connection. */
  332. #ifndef CURL_DISABLE_FTP
  333. BIT(ftp_use_epsv); /* As set with CURLOPT_FTP_USE_EPSV, but if we find out
  334. EPSV does not work we disable it for the forthcoming
  335. requests */
  336. BIT(ftp_use_eprt); /* As set with CURLOPT_FTP_USE_EPRT, but if we find out
  337. EPRT does not work we disable it for the forthcoming
  338. requests */
  339. BIT(ftp_use_data_ssl); /* Enabled SSL for the data connection */
  340. BIT(ftp_use_control_ssl); /* Enabled SSL for the control connection */
  341. #endif
  342. #ifndef CURL_DISABLE_NETRC
  343. BIT(netrc); /* name+password provided by netrc */
  344. #endif
  345. BIT(bound); /* set true if bind() has already been done on this socket/
  346. connection */
  347. BIT(upgrade_in_progress); /* protocol upgrade is in progress */
  348. BIT(multiplex); /* connection is multiplexed */
  349. BIT(tcp_fastopen); /* use TCP Fast Open */
  350. BIT(tls_enable_alpn); /* TLS ALPN extension? */
  351. #ifndef CURL_DISABLE_DOH
  352. BIT(doh);
  353. #endif
  354. #ifdef USE_UNIX_SOCKETS
  355. BIT(abstract_unix_socket);
  356. #endif
  357. BIT(sock_accepted); /* TRUE if the SECONDARYSOCKET was created with
  358. accept() */
  359. BIT(parallel_connect); /* set TRUE when a parallel connect attempt has
  360. started (happy eyeballs) */
  361. BIT(aborted); /* connection was aborted, e.g. in unclean state */
  362. BIT(no_reuse); /* connection should not be reused */
  363. BIT(shutdown_handler); /* connection shutdown: handler shut down */
  364. BIT(shutdown_filters); /* connection shutdown: filters shut down */
  365. BIT(in_cpool); /* connection is kept in a connection pool */
  366. };
  367. struct hostname {
  368. char *rawalloc; /* allocated "raw" version of the name */
  369. char *encalloc; /* allocated IDN-encoded version of the name */
  370. char *name; /* name to use internally, might be encoded, might be raw */
  371. const char *dispname; /* name to display, as 'name' might be encoded */
  372. };
  373. /*
  374. * Flags on the keepon member of the Curl_transfer_keeper
  375. */
  376. #define KEEP_NONE 0
  377. #define KEEP_RECV (1<<0) /* there is or may be data to read */
  378. #define KEEP_SEND (1<<1) /* there is or may be data to write */
  379. #define KEEP_RECV_HOLD (1<<2) /* when set, no reading should be done but there
  380. might still be data to read */
  381. #define KEEP_SEND_HOLD (1<<3) /* when set, no writing should be done but there
  382. might still be data to write */
  383. #define KEEP_RECV_PAUSE (1<<4) /* reading is paused */
  384. #define KEEP_SEND_PAUSE (1<<5) /* writing is paused */
  385. /* KEEP_SEND_TIMED is set when the transfer should attempt sending
  386. * at timer (or other) events. A transfer waiting on a timer will
  387. * remove KEEP_SEND to suppress POLLOUTs of the connection.
  388. * Adding KEEP_SEND_TIMED will then attempt to send whenever the transfer
  389. * enters the "readwrite" loop, e.g. when a timer fires.
  390. * This is used in HTTP for 'Expect: 100-continue' waiting. */
  391. #define KEEP_SEND_TIMED (1<<6)
  392. #define KEEP_RECVBITS (KEEP_RECV | KEEP_RECV_HOLD | KEEP_RECV_PAUSE)
  393. #define KEEP_SENDBITS (KEEP_SEND | KEEP_SEND_HOLD | KEEP_SEND_PAUSE)
  394. /* transfer wants to send is not PAUSE or HOLD */
  395. #define CURL_WANT_SEND(data) \
  396. (((data)->req.keepon & KEEP_SENDBITS) == KEEP_SEND)
  397. /* transfer receive is not on PAUSE or HOLD */
  398. #define CURL_WANT_RECV(data) \
  399. (((data)->req.keepon & KEEP_RECVBITS) == KEEP_RECV)
  400. #define FIRSTSOCKET 0
  401. #define SECONDARYSOCKET 1
  402. /*
  403. * Specific protocol handler.
  404. */
  405. struct Curl_handler {
  406. const char *scheme; /* URL scheme name in lowercase */
  407. /* Complement to setup_connection_internals(). This is done before the
  408. transfer "owns" the connection. */
  409. CURLcode (*setup_connection)(struct Curl_easy *data,
  410. struct connectdata *conn);
  411. /* These two functions MUST be set to be protocol dependent */
  412. CURLcode (*do_it)(struct Curl_easy *data, bool *done);
  413. CURLcode (*done)(struct Curl_easy *, CURLcode, bool);
  414. /* If the curl_do() function is better made in two halves, this
  415. * curl_do_more() function will be called afterwards, if set. For example
  416. * for doing the FTP stuff after the PASV/PORT command.
  417. */
  418. CURLcode (*do_more)(struct Curl_easy *, int *);
  419. /* This function *MAY* be set to a protocol-dependent function that is run
  420. * after the connect() and everything is done, as a step in the connection.
  421. * The 'done' pointer points to a bool that should be set to TRUE if the
  422. * function completes before return. If it does not complete, the caller
  423. * should call the ->connecting() function until it is.
  424. */
  425. CURLcode (*connect_it)(struct Curl_easy *data, bool *done);
  426. /* See above. */
  427. CURLcode (*connecting)(struct Curl_easy *data, bool *done);
  428. CURLcode (*doing)(struct Curl_easy *data, bool *done);
  429. /* Called from the multi interface during the PROTOCONNECT phase, and it
  430. should then return a proper fd set */
  431. CURLcode (*proto_pollset)(struct Curl_easy *data,
  432. struct easy_pollset *ps);
  433. /* Called from the multi interface during the DOING phase, and it should
  434. then return a proper fd set */
  435. CURLcode (*doing_pollset)(struct Curl_easy *data,
  436. struct easy_pollset *ps);
  437. /* Called from the multi interface during the DO_MORE phase, and it should
  438. then return a proper fd set */
  439. CURLcode (*domore_pollset)(struct Curl_easy *data,
  440. struct easy_pollset *ps);
  441. /* Called from the multi interface during the DO_DONE, PERFORM and
  442. WAITPERFORM phases, and it should then return a proper fd set. Not setting
  443. this will make libcurl use the generic default one. */
  444. CURLcode (*perform_pollset)(struct Curl_easy *data,
  445. struct easy_pollset *ps);
  446. /* This function *MAY* be set to a protocol-dependent function that is run
  447. * by the curl_disconnect(), as a step in the disconnection. If the handler
  448. * is called because the connection has been considered dead,
  449. * dead_connection is set to TRUE. The connection is (again) associated with
  450. * the transfer here.
  451. */
  452. CURLcode (*disconnect)(struct Curl_easy *, struct connectdata *,
  453. bool dead_connection);
  454. /* If used, this function gets called from transfer.c to
  455. allow the protocol to do extra handling in writing response to
  456. the client. */
  457. CURLcode (*write_resp)(struct Curl_easy *data, const char *buf, size_t blen,
  458. bool is_eos);
  459. /* If used, this function gets called from transfer.c to
  460. allow the protocol to do extra handling in writing a single response
  461. header line to the client. */
  462. CURLcode (*write_resp_hd)(struct Curl_easy *data,
  463. const char *hd, size_t hdlen, bool is_eos);
  464. /* This function can perform various checks on the connection. See
  465. CONNCHECK_* for more information about the checks that can be performed,
  466. and CONNRESULT_* for the results that can be returned. */
  467. unsigned int (*connection_check)(struct Curl_easy *data,
  468. struct connectdata *conn,
  469. unsigned int checks_to_perform);
  470. /* attach() attaches this transfer to this connection */
  471. void (*attach)(struct Curl_easy *data, struct connectdata *conn);
  472. /* return CURLE_OK if a redirect to `newurl` should be followed,
  473. CURLE_TOO_MANY_REDIRECTS otherwise. May alter `data` to change
  474. the way the follow request is performed. */
  475. CURLcode (*follow)(struct Curl_easy *data, const char *newurl,
  476. followtype type);
  477. int defport; /* Default port. */
  478. curl_prot_t protocol; /* See CURLPROTO_* - this needs to be the single
  479. specific protocol bit */
  480. curl_prot_t family; /* single bit for protocol family; basically the
  481. non-TLS name of the protocol this is */
  482. unsigned int flags; /* Extra particular characteristics, see PROTOPT_* */
  483. };
  484. #define PROTOPT_NONE 0 /* nothing extra */
  485. #define PROTOPT_SSL (1<<0) /* uses SSL */
  486. #define PROTOPT_DUAL (1<<1) /* this protocol uses two connections */
  487. #define PROTOPT_CLOSEACTION (1<<2) /* need action before socket close */
  488. /* some protocols will have to call the underlying functions without regard to
  489. what exact state the socket signals. IE even if the socket says "readable",
  490. the send function might need to be called while uploading, or vice versa.
  491. */
  492. #define PROTOPT_DIRLOCK (1<<3)
  493. #define PROTOPT_NONETWORK (1<<4) /* protocol does not use the network! */
  494. #define PROTOPT_NEEDSPWD (1<<5) /* needs a password, and if none is set it
  495. gets a default */
  496. #define PROTOPT_NOURLQUERY (1<<6) /* protocol cannot handle
  497. URL query strings (?foo=bar) ! */
  498. #define PROTOPT_CREDSPERREQUEST (1<<7) /* requires login credentials per
  499. request instead of per connection */
  500. #define PROTOPT_ALPN (1<<8) /* set ALPN for this */
  501. /* (1<<9) was PROTOPT_STREAM, now free */
  502. #define PROTOPT_URLOPTIONS (1<<10) /* allow options part in the userinfo field
  503. of the URL */
  504. #define PROTOPT_PROXY_AS_HTTP (1<<11) /* allow this non-HTTP scheme over a
  505. HTTP proxy as HTTP proxies may know
  506. this protocol and act as a gateway */
  507. #define PROTOPT_WILDCARD (1<<12) /* protocol supports wildcard matching */
  508. #define PROTOPT_USERPWDCTRL (1<<13) /* Allow "control bytes" (< 32 ASCII) in
  509. username and password */
  510. #define PROTOPT_NOTCPPROXY (1<<14) /* this protocol cannot proxy over TCP */
  511. #define PROTOPT_SSL_REUSE (1<<15) /* this protocol may reuse an existing
  512. SSL connection in the same family
  513. without having PROTOPT_SSL. */
  514. #define CONNCHECK_NONE 0 /* No checks */
  515. #define CONNCHECK_ISDEAD (1<<0) /* Check if the connection is dead. */
  516. #define CONNCHECK_KEEPALIVE (1<<1) /* Perform any keepalive function. */
  517. #define CONNRESULT_NONE 0 /* No extra information. */
  518. #define CONNRESULT_DEAD (1<<0) /* The connection is dead. */
  519. struct ip_quadruple {
  520. char remote_ip[MAX_IPADR_LEN];
  521. char local_ip[MAX_IPADR_LEN];
  522. int remote_port;
  523. int local_port;
  524. };
  525. struct proxy_info {
  526. struct hostname host;
  527. int port;
  528. unsigned char proxytype; /* what kind of proxy that is in use */
  529. char *user; /* proxy username string, allocated */
  530. char *passwd; /* proxy password string, allocated */
  531. };
  532. #define TRNSPRT_TCP 3
  533. #define TRNSPRT_UDP 4
  534. #define TRNSPRT_QUIC 5
  535. #define TRNSPRT_UNIX 6
  536. /*
  537. * The connectdata struct contains all fields and variables that should be
  538. * unique for an entire connection.
  539. */
  540. struct connectdata {
  541. struct Curl_llist_node cpool_node; /* conncache lists */
  542. struct Curl_llist_node cshutdn_node; /* cshutdn list */
  543. curl_closesocket_callback fclosesocket; /* function closing the socket(s) */
  544. void *closesocket_client;
  545. /* This is used by the connection pool logic. If this returns TRUE, this
  546. handle is still used by one or more easy handles and can only used by any
  547. other easy handle without careful consideration (== only for
  548. multiplexing) and it cannot be used by another multi handle! */
  549. #define CONN_INUSE(c) (!Curl_uint_spbset_empty(&(c)->xfers_attached))
  550. #define CONN_ATTACHED(c) Curl_uint_spbset_count(&(c)->xfers_attached)
  551. /**** Fields set when inited and not modified again */
  552. curl_off_t connection_id; /* Contains a unique number to make it easier to
  553. track the connections in the log output */
  554. char *destination; /* string carrying normalized hostname+port+scope */
  555. /* `meta_hash` is a general key-value store for implementations
  556. * with the lifetime of the connection.
  557. * Elements need to be added with their own destructor to be invoked when
  558. * the connection is cleaned up (see Curl_hash_add2()).*/
  559. struct Curl_hash meta_hash;
  560. struct hostname host;
  561. char *hostname_resolve; /* hostname to resolve to address, allocated */
  562. char *secondaryhostname; /* secondary socket hostname (ftp) */
  563. struct hostname conn_to_host; /* the host to connect to. valid only if
  564. bits.conn_to_host is set */
  565. #ifndef CURL_DISABLE_PROXY
  566. struct proxy_info socks_proxy;
  567. struct proxy_info http_proxy;
  568. #endif
  569. char *user; /* username string, allocated */
  570. char *passwd; /* password string, allocated */
  571. char *options; /* options string, allocated */
  572. char *sasl_authzid; /* authorization identity string, allocated */
  573. char *oauth_bearer; /* OAUTH2 bearer, allocated */
  574. struct curltime created; /* creation time */
  575. struct curltime lastused; /* when returned to the connection poolas idle */
  576. /* A connection can have one or two sockets and connection filters.
  577. * The protocol using the 2nd one is FTP for CONTROL+DATA sockets */
  578. curl_socket_t sock[2];
  579. struct Curl_cfilter *cfilter[2]; /* connection filters */
  580. Curl_recv *recv[2];
  581. Curl_send *send[2];
  582. int recv_idx; /* on which socket index to receive, default 0 */
  583. int send_idx; /* on which socket index to send, default 0 */
  584. #define CONN_SOCK_IDX_VALID(i) (((i) >= 0) && ((i) < 2))
  585. struct {
  586. struct curltime start[2]; /* when filter shutdown started */
  587. timediff_t timeout_ms; /* 0 means no timeout */
  588. } shutdown;
  589. struct ssl_primary_config ssl_config;
  590. #ifndef CURL_DISABLE_PROXY
  591. struct ssl_primary_config proxy_ssl_config;
  592. #endif
  593. struct ConnectBits bits; /* various state-flags for this connection */
  594. const struct Curl_handler *handler; /* Connection's protocol handler */
  595. const struct Curl_handler *given; /* The protocol first given */
  596. /* Protocols can use a custom keepalive mechanism to keep connections alive.
  597. This allows those protocols to track the last time the keepalive mechanism
  598. was used on this connection. */
  599. struct curltime keepalive;
  600. struct uint_spbset xfers_attached; /* mids of attached transfers */
  601. /* A connection cache from a SHARE might be used in several multi handles.
  602. * We MUST not reuse connections that are running in another multi,
  603. * for concurrency reasons. That multi might run in another thread.
  604. * `attached_multi` is set by the first transfer attached and cleared
  605. * when the last one is detached.
  606. * NEVER call anything on this multi, just check for equality. */
  607. struct Curl_multi *attached_multi;
  608. /*************** Request - specific items ************/
  609. #if defined(USE_WINDOWS_SSPI) && defined(SECPKG_ATTR_ENDPOINT_BINDINGS)
  610. CtxtHandle *sslContext; /* mingw-w64 v9+. MS SDK 7.0A+. */
  611. #endif
  612. #ifdef USE_NTLM
  613. curlntlm http_ntlm_state;
  614. curlntlm proxy_ntlm_state;
  615. #endif
  616. #ifdef USE_SPNEGO
  617. curlnegotiate http_negotiate_state;
  618. curlnegotiate proxy_negotiate_state;
  619. #endif
  620. #ifdef USE_UNIX_SOCKETS
  621. char *unix_domain_socket;
  622. #endif
  623. /* When this connection is created, store the conditions for the local end
  624. bind. This is stored before the actual bind and before any connection is
  625. made and will serve the purpose of being used for comparison reasons so
  626. that subsequent bound-requested connections are not accidentally reusing
  627. wrong connections. */
  628. char *localdev;
  629. unsigned short localportrange;
  630. int waitfor; /* current READ/WRITE bits to wait for */
  631. #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
  632. int socks5_gssapi_enctype;
  633. #endif
  634. /* The field below gets set in connect.c:connecthost() */
  635. int remote_port; /* the remote port, not the proxy port! */
  636. int conn_to_port; /* the remote port to connect to. valid only if
  637. bits.conn_to_port is set */
  638. #ifdef USE_IPV6
  639. unsigned int scope_id; /* Scope id for IPv6 */
  640. #endif
  641. unsigned short localport;
  642. unsigned short secondary_port; /* secondary socket remote port to connect to
  643. (ftp) */
  644. unsigned char transport_wanted; /* one of the TRNSPRT_* defines. Not
  645. necessarily the transport the connection ends using due to Alt-Svc
  646. and happy eyeballing. Use `Curl_conn_get_transport() for actual value
  647. once the connection is set up. */
  648. unsigned char ip_version; /* copied from the Curl_easy at creation time */
  649. /* HTTP version last responded with by the server or negotiated via ALPN.
  650. * 0 at start, then one of 09, 10, 11, etc. */
  651. unsigned char httpversion_seen;
  652. unsigned char connect_only;
  653. unsigned char gssapi_delegation; /* inherited from set.gssapi_delegation */
  654. };
  655. #ifndef CURL_DISABLE_PROXY
  656. #define CURL_CONN_HOST_DISPNAME(c) \
  657. ((c)->bits.socksproxy ? (c)->socks_proxy.host.dispname : \
  658. (c)->bits.httpproxy ? (c)->http_proxy.host.dispname : \
  659. (c)->bits.conn_to_host ? (c)->conn_to_host.dispname : \
  660. (c)->host.dispname)
  661. #else
  662. #define CURL_CONN_HOST_DISPNAME(c) \
  663. (c)->bits.conn_to_host ? (c)->conn_to_host.dispname : \
  664. (c)->host.dispname
  665. #endif
  666. /* The end of connectdata. */
  667. /*
  668. * Struct to keep statistical and informational data.
  669. * All variables in this struct must be initialized/reset in Curl_initinfo().
  670. */
  671. struct PureInfo {
  672. int httpcode; /* Recent HTTP, FTP, RTSP or SMTP response code */
  673. int httpproxycode; /* response code from proxy when received separate */
  674. int httpversion; /* the http version number X.Y = X*10+Y */
  675. time_t filetime; /* If requested, this is might get set. Set to -1 if the
  676. time was unretrievable. */
  677. curl_off_t request_size; /* the amount of bytes sent in the request(s) */
  678. unsigned long proxyauthavail; /* what proxy auth types were announced */
  679. unsigned long httpauthavail; /* what host auth types were announced */
  680. unsigned long proxyauthpicked; /* selected proxy auth type */
  681. unsigned long httpauthpicked; /* selected host auth type */
  682. long numconnects; /* how many new connection did libcurl created */
  683. char *contenttype; /* the content type of the object */
  684. char *wouldredirect; /* URL this would have been redirected to if asked to */
  685. curl_off_t retry_after; /* info from Retry-After: header */
  686. unsigned int header_size; /* size of read header(s) in bytes */
  687. /* PureInfo primary ip_quadruple is copied over from the connectdata
  688. struct in order to allow curl_easy_getinfo() to return this information
  689. even when the session handle is no longer associated with a connection,
  690. and also allow curl_easy_reset() to clear this information from the
  691. session handle without disturbing information which is still alive, and
  692. that might be reused, in the connection pool. */
  693. struct ip_quadruple primary;
  694. int conn_remote_port; /* this is the "remote port", which is the port
  695. number of the used URL, independent of proxy or
  696. not */
  697. const char *conn_scheme;
  698. unsigned int conn_protocol;
  699. struct curl_certinfo certs; /* info about the certs. Asked for with
  700. CURLOPT_CERTINFO / CURLINFO_CERTINFO */
  701. CURLproxycode pxcode;
  702. BIT(timecond); /* set to TRUE if the time condition did not match, which
  703. thus made the document NOT get fetched */
  704. BIT(used_proxy); /* the transfer used a proxy */
  705. };
  706. struct pgrs_measure {
  707. struct curltime start; /* when measure started */
  708. curl_off_t start_size; /* the 'cur_size' the measure started at */
  709. };
  710. struct pgrs_dir {
  711. curl_off_t total_size; /* total expected bytes */
  712. curl_off_t cur_size; /* transferred bytes so far */
  713. curl_off_t speed; /* bytes per second transferred */
  714. struct pgrs_measure limit;
  715. };
  716. struct Progress {
  717. time_t lastshow; /* time() of the last displayed progress meter or NULL to
  718. force redraw at next call */
  719. struct pgrs_dir ul;
  720. struct pgrs_dir dl;
  721. curl_off_t current_speed; /* uses the currently fastest transfer */
  722. curl_off_t earlydata_sent;
  723. timediff_t timespent;
  724. timediff_t t_postqueue;
  725. timediff_t t_nslookup;
  726. timediff_t t_connect;
  727. timediff_t t_appconnect;
  728. timediff_t t_pretransfer;
  729. timediff_t t_posttransfer;
  730. timediff_t t_starttransfer;
  731. timediff_t t_redirect;
  732. struct curltime start;
  733. struct curltime t_startsingle;
  734. struct curltime t_startop;
  735. struct curltime t_startqueue;
  736. struct curltime t_acceptdata;
  737. #define CURR_TIME (5 + 1) /* 6 entries for 5 seconds */
  738. curl_off_t speeder[ CURR_TIME ];
  739. struct curltime speeder_time[ CURR_TIME ];
  740. unsigned char speeder_c;
  741. BIT(hide);
  742. BIT(ul_size_known);
  743. BIT(dl_size_known);
  744. BIT(headers_out); /* when the headers have been written */
  745. BIT(callback); /* set when progress callback is used */
  746. BIT(is_t_startransfer_set);
  747. };
  748. typedef enum {
  749. RTSPREQ_NONE, /* first in list */
  750. RTSPREQ_OPTIONS,
  751. RTSPREQ_DESCRIBE,
  752. RTSPREQ_ANNOUNCE,
  753. RTSPREQ_SETUP,
  754. RTSPREQ_PLAY,
  755. RTSPREQ_PAUSE,
  756. RTSPREQ_TEARDOWN,
  757. RTSPREQ_GET_PARAMETER,
  758. RTSPREQ_SET_PARAMETER,
  759. RTSPREQ_RECORD,
  760. RTSPREQ_RECEIVE,
  761. RTSPREQ_LAST /* last in list */
  762. } Curl_RtspReq;
  763. struct auth {
  764. unsigned long want; /* Bitmask set to the authentication methods wanted by
  765. app (with CURLOPT_HTTPAUTH or CURLOPT_PROXYAUTH). */
  766. unsigned long picked;
  767. unsigned long avail; /* Bitmask for what the server reports to support for
  768. this resource */
  769. BIT(done); /* TRUE when the auth phase is done and ready to do the
  770. actual request */
  771. BIT(multipass); /* TRUE if this is not yet authenticated but within the
  772. auth multipass negotiation */
  773. BIT(iestyle); /* TRUE if digest should be done IE-style or FALSE if it
  774. should be RFC compliant */
  775. };
  776. #ifdef USE_NGHTTP2
  777. struct Curl_data_prio_node {
  778. struct Curl_data_prio_node *next;
  779. struct Curl_easy *data;
  780. };
  781. #endif
  782. /**
  783. * Priority information for an easy handle in relation to others
  784. * on the same connection.
  785. */
  786. struct Curl_data_priority {
  787. #ifdef USE_NGHTTP2
  788. /* tree like dependencies only implemented in nghttp2 */
  789. struct Curl_easy *parent;
  790. struct Curl_data_prio_node *children;
  791. #endif
  792. int weight;
  793. #ifdef USE_NGHTTP2
  794. BIT(exclusive);
  795. #endif
  796. };
  797. /* Timers */
  798. typedef enum {
  799. EXPIRE_100_TIMEOUT,
  800. EXPIRE_ASYNC_NAME,
  801. EXPIRE_CONNECTTIMEOUT,
  802. EXPIRE_DNS_PER_NAME, /* family1 */
  803. EXPIRE_DNS_PER_NAME2, /* family2 */
  804. EXPIRE_HAPPY_EYEBALLS_DNS, /* See asyn-ares.c */
  805. EXPIRE_HAPPY_EYEBALLS,
  806. EXPIRE_MULTI_PENDING,
  807. EXPIRE_SPEEDCHECK,
  808. EXPIRE_TIMEOUT,
  809. EXPIRE_TOOFAST,
  810. EXPIRE_QUIC,
  811. EXPIRE_FTP_ACCEPT,
  812. EXPIRE_ALPN_EYEBALLS,
  813. EXPIRE_SHUTDOWN,
  814. EXPIRE_LAST /* not an actual timer, used as a marker only */
  815. } expire_id;
  816. typedef enum {
  817. TRAILERS_NONE,
  818. TRAILERS_INITIALIZED,
  819. TRAILERS_SENDING,
  820. TRAILERS_DONE
  821. } trailers_state;
  822. /*
  823. * One instance for each timeout an easy handle can set.
  824. */
  825. struct time_node {
  826. struct Curl_llist_node list;
  827. struct curltime time;
  828. expire_id eid;
  829. };
  830. /* individual pieces of the URL */
  831. struct urlpieces {
  832. char *scheme;
  833. char *hostname;
  834. char *port;
  835. char *user;
  836. char *password;
  837. char *options;
  838. char *path;
  839. char *query;
  840. };
  841. #define CREDS_NONE 0
  842. #define CREDS_URL 1 /* from URL */
  843. #define CREDS_OPTION 2 /* set with a CURLOPT_ */
  844. #define CREDS_NETRC 3 /* found in netrc */
  845. struct UrlState {
  846. /* buffers to store authentication data in, as parsed from input options */
  847. struct curltime keeps_speed; /* for the progress meter really */
  848. curl_off_t lastconnect_id; /* The last connection, -1 if undefined */
  849. curl_off_t recent_conn_id; /* The most recent connection used, might no
  850. * longer exist */
  851. struct dynbuf headerb; /* buffer to store headers in */
  852. struct curl_slist *hstslist; /* list of HSTS files set by
  853. curl_easy_setopt(HSTS) calls */
  854. curl_off_t current_speed; /* the ProgressShow() function sets this,
  855. bytes / second */
  856. /* hostname, port number and protocol of the first (not followed) request.
  857. if set, this should be the hostname that we will sent authorization to,
  858. no else. Used to make Location: following not keep sending user+password.
  859. This is strdup()ed data. */
  860. char *first_host;
  861. int first_remote_port;
  862. curl_prot_t first_remote_protocol;
  863. int os_errno; /* filled in with errno whenever an error occurs */
  864. int requests; /* request counter: redirects + authentication retakes */
  865. #ifdef HAVE_SIGNAL
  866. /* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */
  867. void (*prev_signal)(int sig);
  868. #endif
  869. #ifndef CURL_DISABLE_DIGEST_AUTH
  870. struct digestdata digest; /* state data for host Digest auth */
  871. struct digestdata proxydigest; /* state data for proxy Digest auth */
  872. #endif
  873. struct auth authhost; /* auth details for host */
  874. struct auth authproxy; /* auth details for proxy */
  875. struct Curl_dns_entry *dns[2]; /* DNS to connect FIRST/SECONDARY */
  876. #ifdef USE_CURL_ASYNC
  877. struct Curl_async async; /* asynchronous name resolver data */
  878. #endif
  879. #ifdef USE_OPENSSL
  880. /* void instead of ENGINE to avoid bleeding OpenSSL into this header */
  881. void *engine;
  882. /* void instead of OSSL_PROVIDER */
  883. void *provider;
  884. void *baseprov;
  885. void *libctx;
  886. char *propq; /* for a provider */
  887. BIT(provider_loaded);
  888. #endif /* USE_OPENSSL */
  889. struct curltime expiretime; /* set this with Curl_expire() only */
  890. struct Curl_tree timenode; /* for the splay stuff */
  891. struct Curl_llist timeoutlist; /* list of pending timeouts */
  892. struct time_node expires[EXPIRE_LAST]; /* nodes for each expire type */
  893. /* a place to store the most recently set (S)FTP entrypath */
  894. char *most_recent_ftp_entrypath;
  895. char *range; /* range, if used. See README for detailed specification on
  896. this syntax. */
  897. curl_off_t resume_from; /* continue [ftp] transfer from here */
  898. #ifndef CURL_DISABLE_RTSP
  899. /* This RTSP state information survives requests and connections */
  900. long rtsp_next_client_CSeq; /* the session's next client CSeq */
  901. long rtsp_next_server_CSeq; /* the session's next server CSeq */
  902. long rtsp_CSeq_recv; /* most recent CSeq received */
  903. unsigned char rtp_channel_mask[32]; /* for the correctness checking of the
  904. interleaved data */
  905. #endif
  906. curl_off_t infilesize; /* size of file to upload, -1 means unknown.
  907. Copied from set.filesize at start of operation */
  908. #if defined(USE_HTTP2) || defined(USE_HTTP3)
  909. struct Curl_data_priority priority; /* shallow copy of data->set */
  910. #endif
  911. curl_read_callback fread_func; /* read callback/function */
  912. void *in; /* CURLOPT_READDATA */
  913. CURLU *uh; /* URL handle for the current parsed URL */
  914. struct urlpieces up;
  915. char *url; /* work URL, copied from UserDefined */
  916. char *referer; /* referer string */
  917. struct curl_slist *resolve; /* set to point to the set.resolve list when
  918. this should be dealt with in pretransfer */
  919. #ifndef CURL_DISABLE_HTTP
  920. curl_mimepart *mimepost;
  921. #ifndef CURL_DISABLE_FORM_API
  922. curl_mimepart *formp; /* storage for old API form-posting, allocated on
  923. demand */
  924. #endif
  925. size_t trailers_bytes_sent;
  926. struct dynbuf trailers_buf; /* a buffer containing the compiled trailing
  927. headers */
  928. struct Curl_llist httphdrs; /* received headers */
  929. struct curl_header headerout[2]; /* for external purposes */
  930. struct Curl_header_store *prevhead; /* the latest added header */
  931. trailers_state trailers_state; /* whether we are sending trailers
  932. and what stage are we at */
  933. #endif
  934. #ifndef CURL_DISABLE_COOKIES
  935. struct curl_slist *cookielist; /* list of cookie files set by
  936. curl_easy_setopt(COOKIEFILE) calls */
  937. #endif
  938. #ifndef CURL_DISABLE_VERBOSE_STRINGS
  939. struct curl_trc_feat *feat; /* opt. trace feature transfer is part of */
  940. #endif
  941. #ifndef CURL_DISABLE_NETRC
  942. struct store_netrc netrc;
  943. #endif
  944. /* Dynamically allocated strings, MUST be freed before this struct is
  945. killed. */
  946. struct dynamically_allocated_data {
  947. char *uagent;
  948. char *accept_encoding;
  949. char *userpwd;
  950. char *rangeline;
  951. char *ref;
  952. char *host;
  953. #ifndef CURL_DISABLE_COOKIES
  954. char *cookiehost;
  955. #endif
  956. #ifndef CURL_DISABLE_RTSP
  957. char *rtsp_transport;
  958. #endif
  959. /* transfer credentials */
  960. char *user;
  961. char *passwd;
  962. #ifndef CURL_DISABLE_PROXY
  963. char *proxyuserpwd;
  964. char *proxyuser;
  965. char *proxypasswd;
  966. #endif
  967. } aptr;
  968. #ifndef CURL_DISABLE_HTTP
  969. struct http_negotiation http_neg;
  970. #endif
  971. unsigned short followlocation; /* redirect counter */
  972. unsigned char retrycount; /* number of retries on a new connection, up to
  973. CONN_MAX_RETRIES */
  974. unsigned char httpreq; /* Curl_HttpReq; what kind of HTTP request (if any)
  975. is this */
  976. unsigned int creds_from:2; /* where is the server credentials originating
  977. from, see the CREDS_* defines above */
  978. /* when curl_easy_perform() is called, the multi handle is "owned" by
  979. the easy handle so curl_easy_cleanup() on such an easy handle will
  980. also close the multi handle! */
  981. BIT(multi_owned_by_easy);
  982. BIT(this_is_a_follow); /* this is a followed Location: request */
  983. BIT(refused_stream); /* this was refused, try again */
  984. BIT(errorbuf); /* Set to TRUE if the error buffer is already filled in.
  985. This must be set to FALSE every time _easy_perform() is
  986. called. */
  987. BIT(allow_port); /* Is set.use_port allowed to take effect or not. This
  988. is always set TRUE when curl_easy_perform() is called. */
  989. BIT(authproblem); /* TRUE if there is some problem authenticating */
  990. /* set after initial USER failure, to prevent an authentication loop */
  991. BIT(wildcardmatch); /* enable wildcard matching */
  992. BIT(disableexpect); /* TRUE if Expect: is disabled due to a previous
  993. 417 response */
  994. BIT(use_range);
  995. BIT(rangestringalloc); /* the range string is malloc()'ed */
  996. BIT(done); /* set to FALSE when Curl_init_do() is called and set to TRUE
  997. when multi_done() is called, to prevent multi_done() to get
  998. invoked twice when the multi interface is used. */
  999. #ifndef CURL_DISABLE_COOKIES
  1000. BIT(cookie_engine);
  1001. #endif
  1002. BIT(prefer_ascii); /* ASCII rather than binary */
  1003. #ifdef CURL_LIST_ONLY_PROTOCOL
  1004. BIT(list_only); /* list directory contents */
  1005. #endif
  1006. BIT(url_alloc); /* URL string is malloc()'ed */
  1007. BIT(referer_alloc); /* referer string is malloc()ed */
  1008. BIT(wildcard_resolve); /* Set to true if any resolve change is a wildcard */
  1009. BIT(upload); /* upload request */
  1010. BIT(internal); /* internal: true if this easy handle was created for
  1011. internal use and the user does not have ownership of the
  1012. handle. */
  1013. BIT(http_ignorecustom); /* ignore custom method from now */
  1014. #ifndef CURL_DISABLE_HTTP
  1015. BIT(http_hd_te); /* Added HTTP header TE: */
  1016. BIT(http_hd_upgrade); /* Added HTTP header Upgrade: */
  1017. BIT(http_hd_h2_settings); /* Added HTTP header H2Settings: */
  1018. #endif
  1019. };
  1020. /*
  1021. * This 'UserDefined' struct must only contain data that is set once to go
  1022. * for many (perhaps) independent connections. Values that are generated or
  1023. * calculated internally for the "session handle" MUST be defined within the
  1024. * 'struct UrlState' instead. The only exceptions MUST note the changes in
  1025. * the 'DynamicStatic' struct.
  1026. * Character pointer fields point to dynamic storage, unless otherwise stated.
  1027. */
  1028. struct Curl_multi; /* declared in multihandle.c */
  1029. enum dupstring {
  1030. STRING_CERT, /* client certificate filename */
  1031. STRING_CERT_TYPE, /* format for certificate (default: PEM)*/
  1032. STRING_KEY, /* private key filename */
  1033. STRING_KEY_PASSWD, /* plain text private key password */
  1034. STRING_KEY_TYPE, /* format for private key (default: PEM) */
  1035. STRING_SSL_CAPATH, /* CA directory name (does not work on Windows) */
  1036. STRING_SSL_CAFILE, /* certificate file to verify peer against */
  1037. STRING_SSL_PINNEDPUBLICKEY, /* public key file to verify peer against */
  1038. STRING_SSL_CIPHER_LIST, /* list of ciphers to use */
  1039. STRING_SSL_CIPHER13_LIST, /* list of TLS 1.3 ciphers to use */
  1040. STRING_SSL_CRLFILE, /* crl file to check certificate */
  1041. STRING_SSL_ISSUERCERT, /* issuer cert file to check certificate */
  1042. STRING_SERVICE_NAME, /* Service name */
  1043. #ifndef CURL_DISABLE_PROXY
  1044. STRING_CERT_PROXY, /* client certificate filename */
  1045. STRING_CERT_TYPE_PROXY, /* format for certificate (default: PEM)*/
  1046. STRING_KEY_PROXY, /* private key filename */
  1047. STRING_KEY_PASSWD_PROXY, /* plain text private key password */
  1048. STRING_KEY_TYPE_PROXY, /* format for private key (default: PEM) */
  1049. STRING_SSL_CAPATH_PROXY, /* CA directory name (does not work on Windows) */
  1050. STRING_SSL_CAFILE_PROXY, /* certificate file to verify peer against */
  1051. STRING_SSL_PINNEDPUBLICKEY_PROXY, /* public key file to verify proxy */
  1052. STRING_SSL_CIPHER_LIST_PROXY, /* list of ciphers to use */
  1053. STRING_SSL_CIPHER13_LIST_PROXY, /* list of TLS 1.3 ciphers to use */
  1054. STRING_SSL_CRLFILE_PROXY, /* crl file to check certificate */
  1055. STRING_SSL_ISSUERCERT_PROXY, /* issuer cert file to check certificate */
  1056. STRING_PROXY_SERVICE_NAME, /* Proxy service name */
  1057. #endif
  1058. #ifndef CURL_DISABLE_COOKIES
  1059. STRING_COOKIE, /* HTTP cookie string to send */
  1060. STRING_COOKIEJAR, /* dump all cookies to this file */
  1061. #endif
  1062. STRING_CUSTOMREQUEST, /* HTTP/FTP/RTSP request/method to use */
  1063. STRING_DEFAULT_PROTOCOL, /* Protocol to use when the URL does not specify */
  1064. STRING_DEVICE, /* local network interface/address to use */
  1065. STRING_INTERFACE, /* local network interface to use */
  1066. STRING_BINDHOST, /* local address to use */
  1067. STRING_ENCODING, /* Accept-Encoding string */
  1068. #ifndef CURL_DISABLE_FTP
  1069. STRING_FTP_ACCOUNT, /* ftp account data */
  1070. STRING_FTP_ALTERNATIVE_TO_USER, /* command to send if USER/PASS fails */
  1071. STRING_FTPPORT, /* port to send with the FTP PORT command */
  1072. #endif
  1073. #ifndef CURL_DISABLE_NETRC
  1074. STRING_NETRC_FILE, /* if not NULL, use this instead of trying to find
  1075. $HOME/.netrc */
  1076. #endif
  1077. #ifndef CURL_DISABLE_PROXY
  1078. STRING_PROXY, /* proxy to use */
  1079. STRING_PRE_PROXY, /* pre socks proxy to use */
  1080. #endif
  1081. STRING_SET_RANGE, /* range, if used */
  1082. STRING_SET_REFERER, /* custom string for the HTTP referer field */
  1083. STRING_SET_URL, /* what original URL to work on */
  1084. STRING_USERAGENT, /* User-Agent string */
  1085. STRING_SSL_ENGINE, /* name of ssl engine */
  1086. STRING_USERNAME, /* <username>, if used */
  1087. STRING_PASSWORD, /* <password>, if used */
  1088. STRING_OPTIONS, /* <options>, if used */
  1089. #ifndef CURL_DISABLE_PROXY
  1090. STRING_PROXYUSERNAME, /* Proxy <username>, if used */
  1091. STRING_PROXYPASSWORD, /* Proxy <password>, if used */
  1092. STRING_NOPROXY, /* List of hosts which should not use the proxy, if
  1093. used */
  1094. #endif
  1095. #ifndef CURL_DISABLE_RTSP
  1096. STRING_RTSP_SESSION_ID, /* Session ID to use */
  1097. STRING_RTSP_STREAM_URI, /* Stream URI for this request */
  1098. STRING_RTSP_TRANSPORT, /* Transport for this session */
  1099. #endif
  1100. #ifdef USE_SSH
  1101. STRING_SSH_PRIVATE_KEY, /* path to the private key file for auth */
  1102. STRING_SSH_PUBLIC_KEY, /* path to the public key file for auth */
  1103. STRING_SSH_HOST_PUBLIC_KEY_MD5, /* md5 of host public key in ASCII hex */
  1104. STRING_SSH_HOST_PUBLIC_KEY_SHA256, /* sha256 of host public key in base64 */
  1105. STRING_SSH_KNOWNHOSTS, /* filename of knownhosts file */
  1106. #endif
  1107. #ifndef CURL_DISABLE_SMTP
  1108. STRING_MAIL_FROM,
  1109. STRING_MAIL_AUTH,
  1110. #endif
  1111. #ifdef USE_TLS_SRP
  1112. STRING_TLSAUTH_USERNAME, /* TLS auth <username> */
  1113. STRING_TLSAUTH_PASSWORD, /* TLS auth <password> */
  1114. #ifndef CURL_DISABLE_PROXY
  1115. STRING_TLSAUTH_USERNAME_PROXY, /* TLS auth <username> */
  1116. STRING_TLSAUTH_PASSWORD_PROXY, /* TLS auth <password> */
  1117. #endif
  1118. #endif
  1119. STRING_BEARER, /* <bearer>, if used */
  1120. #ifdef USE_UNIX_SOCKETS
  1121. STRING_UNIX_SOCKET_PATH, /* path to Unix socket, if used */
  1122. #endif
  1123. STRING_TARGET, /* CURLOPT_REQUEST_TARGET */
  1124. #ifndef CURL_DISABLE_DOH
  1125. STRING_DOH, /* CURLOPT_DOH_URL */
  1126. #endif
  1127. #ifndef CURL_DISABLE_ALTSVC
  1128. STRING_ALTSVC, /* CURLOPT_ALTSVC */
  1129. #endif
  1130. #ifndef CURL_DISABLE_HSTS
  1131. STRING_HSTS, /* CURLOPT_HSTS */
  1132. #endif
  1133. STRING_SASL_AUTHZID, /* CURLOPT_SASL_AUTHZID */
  1134. #ifdef USE_ARES
  1135. STRING_DNS_SERVERS,
  1136. STRING_DNS_INTERFACE,
  1137. STRING_DNS_LOCAL_IP4,
  1138. STRING_DNS_LOCAL_IP6,
  1139. #endif
  1140. STRING_SSL_EC_CURVES,
  1141. #ifndef CURL_DISABLE_AWS
  1142. STRING_AWS_SIGV4, /* Parameters for V4 signature */
  1143. #endif
  1144. #ifndef CURL_DISABLE_PROXY
  1145. STRING_HAPROXY_CLIENT_IP, /* CURLOPT_HAPROXY_CLIENT_IP */
  1146. #endif
  1147. STRING_ECH_CONFIG, /* CURLOPT_ECH_CONFIG */
  1148. STRING_ECH_PUBLIC, /* CURLOPT_ECH_PUBLIC */
  1149. STRING_SSL_SIGNATURE_ALGORITHMS, /* CURLOPT_SSL_SIGNATURE_ALGORITHMS */
  1150. /* -- end of null-terminated strings -- */
  1151. STRING_LASTZEROTERMINATED,
  1152. /* -- below this are pointers to binary data that cannot be strdup'ed. --- */
  1153. STRING_COPYPOSTFIELDS, /* if POST, set the fields' values here */
  1154. STRING_LAST /* not used, just an end-of-list marker */
  1155. };
  1156. enum dupblob {
  1157. BLOB_CERT,
  1158. BLOB_KEY,
  1159. BLOB_SSL_ISSUERCERT,
  1160. BLOB_CAINFO,
  1161. #ifndef CURL_DISABLE_PROXY
  1162. BLOB_CERT_PROXY,
  1163. BLOB_KEY_PROXY,
  1164. BLOB_SSL_ISSUERCERT_PROXY,
  1165. BLOB_CAINFO_PROXY,
  1166. #endif
  1167. BLOB_LAST
  1168. };
  1169. struct UserDefined {
  1170. FILE *err; /* the stderr user data goes here */
  1171. void *debugdata; /* the data that will be passed to fdebug */
  1172. char *errorbuffer; /* (Static) store failure messages in here */
  1173. void *out; /* CURLOPT_WRITEDATA */
  1174. void *in_set; /* CURLOPT_READDATA */
  1175. void *writeheader; /* write the header to this if non-NULL */
  1176. unsigned long httpauth; /* kind of HTTP authentication to use (bitmask) */
  1177. unsigned long proxyauth; /* kind of proxy authentication to use (bitmask) */
  1178. void *postfields; /* if POST, set the fields' values here */
  1179. curl_seek_callback seek_func; /* function that seeks the input */
  1180. curl_off_t postfieldsize; /* if POST, this might have a size to use instead
  1181. of strlen(), and then the data *may* be binary
  1182. (contain zero bytes) */
  1183. curl_write_callback fwrite_func; /* function that stores the output */
  1184. curl_write_callback fwrite_header; /* function that stores headers */
  1185. curl_write_callback fwrite_rtp; /* function that stores interleaved RTP */
  1186. curl_read_callback fread_func_set; /* function that reads the input */
  1187. curl_progress_callback fprogress; /* OLD and deprecated progress callback */
  1188. curl_xferinfo_callback fxferinfo; /* progress callback */
  1189. curl_debug_callback fdebug; /* function that write informational data */
  1190. curl_ioctl_callback ioctl_func; /* function for I/O control */
  1191. curl_sockopt_callback fsockopt; /* function for setting socket options */
  1192. void *sockopt_client; /* pointer to pass to the socket options callback */
  1193. curl_opensocket_callback fopensocket; /* function for checking/translating
  1194. the address and opening the
  1195. socket */
  1196. void *opensocket_client;
  1197. curl_closesocket_callback fclosesocket; /* function for closing the
  1198. socket */
  1199. void *closesocket_client;
  1200. curl_prereq_callback fprereq; /* pre-initial request callback */
  1201. void *prereq_userp; /* pre-initial request user data */
  1202. void *seek_client; /* pointer to pass to the seek callback */
  1203. #ifndef CURL_DISABLE_HSTS
  1204. curl_hstsread_callback hsts_read;
  1205. void *hsts_read_userp;
  1206. curl_hstswrite_callback hsts_write;
  1207. void *hsts_write_userp;
  1208. #endif
  1209. void *progress_client; /* pointer to pass to the progress callback */
  1210. void *ioctl_client; /* pointer to pass to the ioctl callback */
  1211. timediff_t conn_max_idle_ms; /* max idle time to allow a connection that
  1212. is to be reused */
  1213. timediff_t conn_max_age_ms; /* max time since creation to allow a
  1214. connection that is to be reused */
  1215. curl_off_t filesize; /* size of file to upload, -1 means unknown */
  1216. long low_speed_limit; /* bytes/second */
  1217. long low_speed_time; /* number of seconds */
  1218. curl_off_t max_send_speed; /* high speed limit in bytes/second for upload */
  1219. curl_off_t max_recv_speed; /* high speed limit in bytes/second for
  1220. download */
  1221. curl_off_t set_resume_from; /* continue [ftp] transfer from here */
  1222. struct curl_slist *headers; /* linked list of extra headers */
  1223. struct curl_httppost *httppost; /* linked list of old POST data */
  1224. #if !defined(CURL_DISABLE_MIME) || !defined(CURL_DISABLE_FORM_API)
  1225. curl_mimepart mimepost; /* MIME/POST data. */
  1226. #endif
  1227. #ifndef CURL_DISABLE_TELNET
  1228. struct curl_slist *telnet_options; /* linked list of telnet options */
  1229. #endif
  1230. struct curl_slist *resolve; /* list of names to add/remove from
  1231. DNS cache */
  1232. struct curl_slist *connect_to; /* list of host:port mappings to override
  1233. the hostname and port to connect to */
  1234. time_t timevalue; /* what time to compare with */
  1235. struct ssl_config_data ssl; /* user defined SSL stuff */
  1236. #ifndef CURL_DISABLE_PROXY
  1237. struct ssl_config_data proxy_ssl; /* user defined SSL stuff for proxy */
  1238. struct curl_slist *proxyheaders; /* linked list of extra CONNECT headers */
  1239. unsigned short proxyport; /* If non-zero, use this port number by
  1240. default. If the proxy string features a
  1241. ":[port]" that one will override this. */
  1242. unsigned char proxytype; /* what kind of proxy */
  1243. unsigned char socks5auth;/* kind of SOCKS5 authentication to use (bitmask) */
  1244. #endif
  1245. struct ssl_general_config general_ssl; /* general user defined SSL stuff */
  1246. timediff_t dns_cache_timeout_ms; /* DNS cache timeout (milliseconds) */
  1247. unsigned int buffer_size; /* size of receive buffer to use */
  1248. unsigned int upload_buffer_size; /* size of upload buffer to use,
  1249. keep it >= CURL_MAX_WRITE_SIZE */
  1250. void *private_data; /* application-private data */
  1251. #ifndef CURL_DISABLE_HTTP
  1252. struct curl_slist *http200aliases; /* linked list of aliases for http200 */
  1253. #endif
  1254. curl_off_t max_filesize; /* Maximum file size to download */
  1255. #ifndef CURL_DISABLE_FTP
  1256. timediff_t accepttimeout; /* in milliseconds, 0 means no timeout */
  1257. unsigned char ftp_filemethod; /* how to get to a file: curl_ftpfile */
  1258. unsigned char ftpsslauth; /* what AUTH XXX to try: curl_ftpauth */
  1259. unsigned char ftp_ccc; /* FTP CCC options: curl_ftpccc */
  1260. #endif
  1261. #if !defined(CURL_DISABLE_FTP) || defined(USE_SSH)
  1262. struct curl_slist *quote; /* after connection is established */
  1263. struct curl_slist *postquote; /* after the transfer */
  1264. struct curl_slist *prequote; /* before the transfer, after type */
  1265. #endif
  1266. #ifdef USE_LIBSSH2
  1267. curl_sshhostkeycallback ssh_hostkeyfunc; /* hostkey check callback */
  1268. void *ssh_hostkeyfunc_userp; /* custom pointer to callback */
  1269. #endif
  1270. #ifdef USE_SSH
  1271. curl_sshkeycallback ssh_keyfunc; /* key matching callback */
  1272. void *ssh_keyfunc_userp; /* custom pointer to callback */
  1273. int ssh_auth_types; /* allowed SSH auth types */
  1274. unsigned int new_directory_perms; /* when creating remote dirs */
  1275. #endif
  1276. unsigned int new_file_perms; /* when creating remote files */
  1277. char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */
  1278. struct curl_blob *blobs[BLOB_LAST];
  1279. #ifdef USE_IPV6
  1280. unsigned int scope_id; /* Scope id for IPv6 */
  1281. #endif
  1282. curl_prot_t allowed_protocols;
  1283. curl_prot_t redir_protocols;
  1284. #ifndef CURL_DISABLE_RTSP
  1285. void *rtp_out; /* write RTP to this if non-NULL */
  1286. /* Common RTSP header options */
  1287. Curl_RtspReq rtspreq; /* RTSP request type */
  1288. #endif
  1289. #ifndef CURL_DISABLE_FTP
  1290. curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer
  1291. starts */
  1292. curl_chunk_end_callback chunk_end; /* called after part transferring
  1293. stopped */
  1294. curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds
  1295. to pattern (e.g. if WILDCARDMATCH is on) */
  1296. void *fnmatch_data;
  1297. void *wildcardptr;
  1298. #endif
  1299. timediff_t timeout; /* ms, 0 means no timeout */
  1300. timediff_t connecttimeout; /* ms, 0 means default timeout */
  1301. timediff_t happy_eyeballs_timeout; /* ms, 0 is a valid value */
  1302. timediff_t server_response_timeout; /* ms, 0 means no timeout */
  1303. timediff_t shutdowntimeout; /* ms, 0 means default timeout */
  1304. int tcp_keepidle; /* seconds in idle before sending keepalive probe */
  1305. int tcp_keepintvl; /* seconds between TCP keepalive probes */
  1306. int tcp_keepcnt; /* maximum number of keepalive probes */
  1307. #if defined(USE_HTTP2) || defined(USE_HTTP3)
  1308. struct Curl_data_priority priority;
  1309. #endif
  1310. curl_resolver_start_callback resolver_start; /* optional callback called
  1311. before resolver start */
  1312. void *resolver_start_client; /* pointer to pass to resolver start callback */
  1313. long upkeep_interval_ms; /* Time between calls for connection upkeep. */
  1314. CURLU *uh; /* URL handle for the current parsed URL */
  1315. #ifndef CURL_DISABLE_HTTP
  1316. void *trailer_data; /* pointer to pass to trailer data callback */
  1317. curl_trailer_callback trailer_callback; /* trailing data callback */
  1318. #endif
  1319. #ifndef CURL_DISABLE_SMTP
  1320. struct curl_slist *mail_rcpt; /* linked list of mail recipients */
  1321. #endif
  1322. unsigned int maxconnects; /* Max idle connections in the connection cache */
  1323. #ifdef USE_ECH
  1324. int tls_ech; /* TLS ECH configuration */
  1325. #endif
  1326. short maxredirs; /* maximum no. of http(s) redirects to follow,
  1327. set to -1 for infinity */
  1328. unsigned short expect_100_timeout; /* in milliseconds */
  1329. unsigned short use_port; /* which port to use (when not using default) */
  1330. #ifndef CURL_DISABLE_BINDLOCAL
  1331. unsigned short localport; /* local port number to bind to */
  1332. unsigned short localportrange; /* number of additional port numbers to test
  1333. in case the 'localport' one cannot be
  1334. bind()ed */
  1335. #endif
  1336. #ifndef CURL_DISABLE_TFTP
  1337. unsigned short tftp_blksize; /* in bytes, 0 means use default */
  1338. #endif
  1339. #ifndef CURL_DISABLE_NETRC
  1340. unsigned char use_netrc; /* enum CURL_NETRC_OPTION values */
  1341. #endif
  1342. #if !defined(CURL_DISABLE_FTP) || defined(USE_SSH)
  1343. /* Despite the name, ftp_create_missing_dirs is for FTP(S) and SFTP
  1344. 1 - create directories that do not exist
  1345. 2 - the same but also allow MKD to fail once
  1346. */
  1347. unsigned char ftp_create_missing_dirs;
  1348. #endif
  1349. unsigned char use_ssl; /* if AUTH TLS is to be attempted etc, for FTP or
  1350. IMAP or POP3 or others! (type: curl_usessl)*/
  1351. char keep_post; /* keep POSTs as POSTs after a 30x request; each
  1352. bit represents a request, from 301 to 303 */
  1353. unsigned char timecondition; /* kind of time comparison: curl_TimeCond */
  1354. unsigned char method; /* what kind of HTTP request: Curl_HttpReq */
  1355. unsigned char httpwant; /* when non-zero, a specific HTTP version requested
  1356. to be used in the library's request(s) */
  1357. unsigned char ipver; /* the CURL_IPRESOLVE_* defines in the public header
  1358. file 0 - whatever, 1 - v2, 2 - v6 */
  1359. unsigned char upload_flags; /* flags set by CURLOPT_UPLOAD_FLAGS */
  1360. #ifdef HAVE_GSSAPI
  1361. /* GSS-API credential delegation, see the documentation of
  1362. CURLOPT_GSSAPI_DELEGATION */
  1363. unsigned char gssapi_delegation;
  1364. #endif
  1365. unsigned char http_follow_mode; /* follow HTTP redirects */
  1366. BIT(connect_only); /* make connection/request, then let application use the
  1367. socket */
  1368. BIT(connect_only_ws); /* special websocket connect-only level */
  1369. #ifndef CURL_DISABLE_SMTP
  1370. BIT(mail_rcpt_allowfails); /* allow RCPT TO command to fail for some
  1371. recipients */
  1372. #endif
  1373. #ifndef CURL_DISABLE_MIME
  1374. BIT(mime_formescape);
  1375. #endif
  1376. BIT(is_fread_set); /* has read callback been set to non-NULL? */
  1377. #ifndef CURL_DISABLE_TFTP
  1378. BIT(tftp_no_options); /* do not send TFTP options requests */
  1379. #endif
  1380. BIT(sep_headers); /* handle host and proxy headers separately */
  1381. #ifndef CURL_DISABLE_COOKIES
  1382. BIT(cookiesession); /* new cookie session? */
  1383. #endif
  1384. BIT(crlf); /* convert crlf on ftp upload(?) */
  1385. #ifdef USE_SSH
  1386. BIT(ssh_compression); /* enable SSH compression */
  1387. #endif
  1388. /* Here follows boolean settings that define how to behave during
  1389. this session. They are STATIC, set by libcurl users or at least initially
  1390. and they do not change during operations. */
  1391. BIT(quick_exit); /* set 1L when it is okay to leak things (like
  1392. threads), as we are about to exit() anyway and
  1393. do not want lengthy cleanups to delay termination,
  1394. e.g. after a DNS timeout */
  1395. BIT(get_filetime); /* get the time and get of the remote file */
  1396. #ifndef CURL_DISABLE_PROXY
  1397. BIT(tunnel_thru_httpproxy); /* use CONNECT through an HTTP proxy */
  1398. #endif
  1399. BIT(prefer_ascii); /* ASCII rather than binary */
  1400. BIT(remote_append); /* append, not overwrite, on upload */
  1401. #ifdef CURL_LIST_ONLY_PROTOCOL
  1402. BIT(list_only); /* list directory */
  1403. #endif
  1404. #ifndef CURL_DISABLE_FTP
  1405. BIT(ftp_use_port); /* use the FTP PORT command */
  1406. BIT(ftp_use_epsv); /* if EPSV is to be attempted or not */
  1407. BIT(ftp_use_eprt); /* if EPRT is to be attempted or not */
  1408. BIT(ftp_use_pret); /* if PRET is to be used before PASV or not */
  1409. BIT(ftp_skip_ip); /* skip the IP address the FTP server passes on to
  1410. us */
  1411. BIT(wildcard_enabled); /* enable wildcard matching */
  1412. #endif
  1413. BIT(http_fail_on_error); /* fail on HTTP error codes >= 400 */
  1414. BIT(http_keep_sending_on_error); /* for HTTP status codes >= 300 */
  1415. BIT(http_transfer_encoding); /* request compressed HTTP transfer-encoding */
  1416. BIT(allow_auth_to_other_hosts);
  1417. BIT(include_header); /* include received protocol headers in data output */
  1418. BIT(http_set_referer); /* is a custom referer used */
  1419. BIT(http_auto_referer); /* set "correct" referer when following
  1420. location: */
  1421. BIT(opt_no_body); /* as set with CURLOPT_NOBODY */
  1422. BIT(verbose); /* output verbosity */
  1423. BIT(reuse_forbid); /* forbidden to be reused, close after use */
  1424. BIT(reuse_fresh); /* do not reuse an existing connection */
  1425. BIT(no_signal); /* do not use any signal/alarm handler */
  1426. BIT(tcp_nodelay); /* whether to enable TCP_NODELAY or not */
  1427. BIT(ignorecl); /* ignore content length */
  1428. BIT(http_te_skip); /* pass the raw body data to the user, even when
  1429. transfer-encoded (chunked, compressed) */
  1430. BIT(http_ce_skip); /* pass the raw body data to the user, even when
  1431. content-encoded (chunked, compressed) */
  1432. BIT(proxy_transfer_mode); /* set transfer mode (;type=<a|i>) when doing
  1433. FTP via an HTTP proxy */
  1434. #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
  1435. BIT(socks5_gssapi_nec); /* Flag to support NEC SOCKS5 server */
  1436. #endif
  1437. BIT(sasl_ir); /* Enable/disable SASL initial response */
  1438. BIT(tcp_keepalive); /* use TCP keepalives */
  1439. BIT(tcp_fastopen); /* use TCP Fast Open */
  1440. BIT(ssl_enable_alpn);/* TLS ALPN extension? */
  1441. BIT(path_as_is); /* allow dotdots? */
  1442. BIT(pipewait); /* wait for multiplex status before starting a new
  1443. connection */
  1444. BIT(suppress_connect_headers); /* suppress proxy CONNECT response headers
  1445. from user callbacks */
  1446. BIT(dns_shuffle_addresses); /* whether to shuffle addresses before use */
  1447. #ifndef CURL_DISABLE_PROXY
  1448. BIT(haproxyprotocol); /* whether to send HAProxy PROXY protocol v1
  1449. header */
  1450. #endif
  1451. #ifdef USE_UNIX_SOCKETS
  1452. BIT(abstract_unix_socket);
  1453. #endif
  1454. BIT(disallow_username_in_url); /* disallow username in URL */
  1455. #ifndef CURL_DISABLE_DOH
  1456. BIT(doh); /* DNS-over-HTTPS enabled */
  1457. BIT(doh_verifypeer); /* DoH certificate peer verification */
  1458. BIT(doh_verifyhost); /* DoH certificate hostname verification */
  1459. BIT(doh_verifystatus); /* DoH certificate status verification */
  1460. #endif
  1461. BIT(http09_allowed); /* allow HTTP/0.9 responses */
  1462. #ifndef CURL_DISABLE_WEBSOCKETS
  1463. BIT(ws_raw_mode);
  1464. BIT(ws_no_auto_pong);
  1465. #endif
  1466. };
  1467. #ifndef CURL_DISABLE_MIME
  1468. #define IS_MIME_POST(a) ((a)->set.mimepost.kind != MIMEKIND_NONE)
  1469. #else
  1470. #define IS_MIME_POST(a) FALSE
  1471. #endif
  1472. /* callback that gets called when a sub easy (data->master_mid set) is
  1473. DONE. Called on the master easy. */
  1474. typedef void multi_sub_xfer_done_cb(struct Curl_easy *master_easy,
  1475. struct Curl_easy *sub_easy,
  1476. CURLcode result);
  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 a simple identifier to easier detect if a user mix up this easy
  1488. handle with a multi handle. Set this to CURLEASY_MAGIC_NUMBER */
  1489. unsigned int magic;
  1490. /* once an easy handle is tied to a connection pool a non-negative number to
  1491. distinguish this transfer from other using the same pool. For easier
  1492. tracking in log output. This may wrap around after LONG_MAX to 0 again,
  1493. so it has no uniqueness guarantee for large processings. Note: it has no
  1494. uniqueness either IFF more than one connection pool is used by the
  1495. libcurl application. */
  1496. curl_off_t id;
  1497. /* once an easy handle is added to a multi, either explicitly by the
  1498. * libcurl application or implicitly during `curl_easy_perform()`,
  1499. * a unique identifier inside this one multi instance. */
  1500. unsigned int mid;
  1501. unsigned int master_mid; /* if set, this transfer belongs to a master */
  1502. multi_sub_xfer_done_cb *sub_xfer_done;
  1503. struct connectdata *conn;
  1504. CURLMstate mstate; /* the handle's state */
  1505. CURLcode result; /* previous result */
  1506. struct Curl_message msg; /* A single posted message. */
  1507. struct Curl_multi *multi; /* if non-NULL, points to the multi handle
  1508. struct to which this "belongs" when used by
  1509. the multi interface */
  1510. struct Curl_multi *multi_easy; /* if non-NULL, points to the multi handle
  1511. struct to which this "belongs" when used
  1512. by the easy interface */
  1513. struct Curl_share *share; /* Share, handles global variable mutexing */
  1514. /* `meta_hash` is a general key-value store for implementations
  1515. * with the lifetime of the easy handle.
  1516. * Elements need to be added with their own destructor to be invoked when
  1517. * the easy handle is cleaned up (see Curl_hash_add2()).*/
  1518. struct Curl_hash meta_hash;
  1519. #ifdef USE_LIBPSL
  1520. struct PslCache *psl; /* The associated PSL cache. */
  1521. #endif
  1522. struct SingleRequest req; /* Request-specific data */
  1523. struct UserDefined set; /* values set by the libcurl user */
  1524. #ifndef CURL_DISABLE_COOKIES
  1525. struct CookieInfo *cookies; /* the cookies, read from files and servers.
  1526. NOTE that the 'cookie' field in the
  1527. UserDefined struct defines if the "engine"
  1528. is to be used or not. */
  1529. #endif
  1530. #ifndef CURL_DISABLE_HSTS
  1531. struct hsts *hsts;
  1532. #endif
  1533. #ifndef CURL_DISABLE_ALTSVC
  1534. struct altsvcinfo *asi; /* the alt-svc cache */
  1535. #endif
  1536. struct Progress progress; /* for all the progress meter data */
  1537. struct UrlState state; /* struct for fields used for state info and
  1538. other dynamic purposes */
  1539. #ifndef CURL_DISABLE_FTP
  1540. struct WildcardData *wildcard; /* wildcard download state info */
  1541. #endif
  1542. struct PureInfo info; /* stats, reports and info data */
  1543. struct curl_tlssessioninfo tsi; /* Information about the TLS session, only
  1544. valid after a client has asked for it */
  1545. };
  1546. #define LIBCURL_NAME "libcurl"
  1547. #endif /* HEADER_CURL_URLDATA_H */