urldata.h 76 KB

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