2
0

urldata.h 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651
  1. #ifndef HEADER_CURL_URLDATA_H
  2. #define HEADER_CURL_URLDATA_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2012, 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 http://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 "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_SMTP 25
  41. #define PORT_SMTPS 465 /* sometimes called SSMTP */
  42. #define PORT_RTSP 554
  43. #define PORT_RTMP 1935
  44. #define PORT_RTMPT PORT_HTTP
  45. #define PORT_RTMPS PORT_HTTPS
  46. #define PORT_GOPHER 70
  47. #define DICT_MATCH "/MATCH:"
  48. #define DICT_MATCH2 "/M:"
  49. #define DICT_MATCH3 "/FIND:"
  50. #define DICT_DEFINE "/DEFINE:"
  51. #define DICT_DEFINE2 "/D:"
  52. #define DICT_DEFINE3 "/LOOKUP:"
  53. #define CURL_DEFAULT_USER "anonymous"
  54. #define CURL_DEFAULT_PASSWORD "ftp@example.com"
  55. /* length of longest IPv6 address string including the trailing null */
  56. #define MAX_IPADR_LEN sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")
  57. /* Default FTP/IMAP etc response timeout in milliseconds.
  58. Symbian OS panics when given a timeout much greater than 1/2 hour.
  59. */
  60. #define RESP_TIMEOUT (1800*1000)
  61. #include "cookie.h"
  62. #include "formdata.h"
  63. #ifdef USE_SSLEAY
  64. #ifdef USE_OPENSSL
  65. #include <openssl/rsa.h>
  66. #include <openssl/crypto.h>
  67. #include <openssl/x509.h>
  68. #include <openssl/pem.h>
  69. #include <openssl/ssl.h>
  70. #include <openssl/err.h>
  71. #ifdef HAVE_OPENSSL_ENGINE_H
  72. #include <openssl/engine.h>
  73. #endif
  74. #ifdef HAVE_OPENSSL_PKCS12_H
  75. #include <openssl/pkcs12.h>
  76. #endif
  77. #else /* SSLeay-style includes */
  78. #include <rsa.h>
  79. #include <crypto.h>
  80. #include <x509.h>
  81. #include <pem.h>
  82. #include <ssl.h>
  83. #include <err.h>
  84. #ifdef HAVE_OPENSSL_ENGINE_H
  85. #include <engine.h>
  86. #endif
  87. #ifdef HAVE_OPENSSL_PKCS12_H
  88. #include <pkcs12.h>
  89. #endif
  90. #endif /* USE_OPENSSL */
  91. #ifdef USE_GNUTLS
  92. #error Configuration error; cannot use GnuTLS *and* OpenSSL.
  93. #endif
  94. #endif /* USE_SSLEAY */
  95. #ifdef USE_GNUTLS
  96. #include <gnutls/gnutls.h>
  97. #endif
  98. #ifdef USE_POLARSSL
  99. #include <polarssl/havege.h>
  100. #include <polarssl/ssl.h>
  101. #endif
  102. #ifdef USE_CYASSL
  103. #undef OCSP_REQUEST /* avoid cyassl/openssl/ssl.h clash with wincrypt.h */
  104. #undef OCSP_RESPONSE /* avoid cyassl/openssl/ssl.h clash with wincrypt.h */
  105. #include <cyassl/openssl/ssl.h>
  106. #endif
  107. #ifdef USE_NSS
  108. #include <nspr.h>
  109. #include <pk11pub.h>
  110. #endif
  111. #ifdef USE_QSOSSL
  112. #include <qsossl.h>
  113. #endif
  114. #ifdef USE_AXTLS
  115. #include <axTLS/ssl.h>
  116. #undef malloc
  117. #undef calloc
  118. #undef realloc
  119. #endif /* USE_AXTLS */
  120. #ifdef USE_SCHANNEL
  121. #include "curl_sspi.h"
  122. #include <schnlsp.h>
  123. #include <schannel.h>
  124. #endif
  125. #ifdef USE_DARWINSSL
  126. #include <Security/Security.h>
  127. /* For some reason, when building for iOS, the omnibus header above does
  128. * not include SecureTransport.h as of iOS SDK 5.1. */
  129. #include <Security/SecureTransport.h>
  130. #endif
  131. #ifdef HAVE_NETINET_IN_H
  132. #include <netinet/in.h>
  133. #endif
  134. #include "timeval.h"
  135. #ifdef HAVE_ZLIB_H
  136. #include <zlib.h> /* for content-encoding */
  137. #ifdef __SYMBIAN32__
  138. /* zlib pollutes the namespace with this definition */
  139. #undef WIN32
  140. #endif
  141. #endif
  142. #include <curl/curl.h>
  143. #include "http_chunks.h" /* for the structs and enum stuff */
  144. #include "hostip.h"
  145. #include "hash.h"
  146. #include "splay.h"
  147. #include "imap.h"
  148. #include "pop3.h"
  149. #include "smtp.h"
  150. #include "ftp.h"
  151. #include "file.h"
  152. #include "ssh.h"
  153. #include "http.h"
  154. #include "rtsp.h"
  155. #include "wildcard.h"
  156. #ifdef HAVE_GSSAPI
  157. # ifdef HAVE_GSSGNU
  158. # include <gss.h>
  159. # elif defined HAVE_GSSMIT
  160. # include <gssapi/gssapi.h>
  161. # include <gssapi/gssapi_generic.h>
  162. # else
  163. # include <gssapi.h>
  164. # endif
  165. #endif
  166. #ifdef HAVE_LIBSSH2_H
  167. #include <libssh2.h>
  168. #include <libssh2_sftp.h>
  169. #endif /* HAVE_LIBSSH2_H */
  170. /* Download buffer size, keep it fairly big for speed reasons */
  171. #undef BUFSIZE
  172. #define BUFSIZE CURL_MAX_WRITE_SIZE
  173. /* Initial size of the buffer to store headers in, it'll be enlarged in case
  174. of need. */
  175. #define HEADERSIZE 256
  176. #define CURLEASY_MAGIC_NUMBER 0xc0dedbadU
  177. /* Some convenience macros to get the larger/smaller value out of two given.
  178. We prefix with CURL to prevent name collisions. */
  179. #define CURLMAX(x,y) ((x)>(y)?(x):(y))
  180. #define CURLMIN(x,y) ((x)<(y)?(x):(y))
  181. #if defined(HAVE_KRB4) || defined(HAVE_GSSAPI)
  182. /* Types needed for krb4/5-ftp connections */
  183. struct krb4buffer {
  184. void *data;
  185. size_t size;
  186. size_t index;
  187. int eof_flag;
  188. };
  189. enum protection_level {
  190. PROT_NONE, /* first in list */
  191. PROT_CLEAR,
  192. PROT_SAFE,
  193. PROT_CONFIDENTIAL,
  194. PROT_PRIVATE,
  195. PROT_CMD,
  196. PROT_LAST /* last in list */
  197. };
  198. #endif
  199. #ifdef USE_SCHANNEL
  200. /* Structs to store Schannel handles */
  201. struct curl_schannel_cred {
  202. CredHandle cred_handle;
  203. TimeStamp time_stamp;
  204. };
  205. struct curl_schannel_ctxt {
  206. CtxtHandle ctxt_handle;
  207. TimeStamp time_stamp;
  208. };
  209. #endif
  210. /* enum for the nonblocking SSL connection state machine */
  211. typedef enum {
  212. ssl_connect_1,
  213. ssl_connect_2,
  214. ssl_connect_2_reading,
  215. ssl_connect_2_writing,
  216. #ifdef USE_DARWINSSL
  217. ssl_connect_2_wouldblock,
  218. #endif /* USE_DARWINSSL */
  219. ssl_connect_3,
  220. ssl_connect_done
  221. } ssl_connect_state;
  222. typedef enum {
  223. ssl_connection_none,
  224. ssl_connection_negotiating,
  225. ssl_connection_complete
  226. } ssl_connection_state;
  227. /* struct for data related to each SSL connection */
  228. struct ssl_connect_data {
  229. /* Use ssl encrypted communications TRUE/FALSE, not necessarily using it atm
  230. but at least asked to or meaning to use it. See 'state' for the exact
  231. current state of the connection. */
  232. bool use;
  233. ssl_connection_state state;
  234. #ifdef USE_SSLEAY
  235. /* these ones requires specific SSL-types */
  236. SSL_CTX* ctx;
  237. SSL* handle;
  238. X509* server_cert;
  239. ssl_connect_state connecting_state;
  240. #endif /* USE_SSLEAY */
  241. #ifdef USE_GNUTLS
  242. gnutls_session session;
  243. gnutls_certificate_credentials cred;
  244. #ifdef USE_TLS_SRP
  245. gnutls_srp_client_credentials srp_client_cred;
  246. #endif
  247. ssl_connect_state connecting_state;
  248. #endif /* USE_GNUTLS */
  249. #ifdef USE_POLARSSL
  250. havege_state hs;
  251. ssl_context ssl;
  252. ssl_session ssn;
  253. int server_fd;
  254. x509_cert cacert;
  255. x509_cert clicert;
  256. x509_crl crl;
  257. rsa_context rsa;
  258. ssl_connect_state connecting_state;
  259. #endif /* USE_POLARSSL */
  260. #ifdef USE_CYASSL
  261. SSL_CTX* ctx;
  262. SSL* handle;
  263. ssl_connect_state connecting_state;
  264. #endif /* USE_CYASSL */
  265. #ifdef USE_NSS
  266. PRFileDesc *handle;
  267. char *client_nickname;
  268. struct SessionHandle *data;
  269. struct curl_llist *obj_list;
  270. PK11GenericObject *obj_clicert;
  271. #endif /* USE_NSS */
  272. #ifdef USE_QSOSSL
  273. SSLHandle *handle;
  274. #endif /* USE_QSOSSL */
  275. #ifdef USE_AXTLS
  276. SSL_CTX* ssl_ctx;
  277. SSL* ssl;
  278. #endif /* USE_AXTLS */
  279. #ifdef USE_SCHANNEL
  280. struct curl_schannel_cred *cred;
  281. struct curl_schannel_ctxt *ctxt;
  282. SecPkgContext_StreamSizes stream_sizes;
  283. ssl_connect_state connecting_state;
  284. size_t encdata_length, decdata_length;
  285. size_t encdata_offset, decdata_offset;
  286. unsigned char *encdata_buffer, *decdata_buffer;
  287. unsigned long req_flags, ret_flags;
  288. #endif /* USE_SCHANNEL */
  289. #ifdef USE_DARWINSSL
  290. SSLContextRef ssl_ctx;
  291. curl_socket_t ssl_sockfd;
  292. ssl_connect_state connecting_state;
  293. #endif /* USE_DARWINSSL */
  294. };
  295. struct ssl_config_data {
  296. long version; /* what version the client wants to use */
  297. long certverifyresult; /* result from the certificate verification */
  298. long verifypeer; /* set TRUE if this is desired */
  299. long verifyhost; /* 0: no verify
  300. 1: check that CN exists
  301. 2: CN must match hostname */
  302. char *CApath; /* certificate dir (doesn't work on windows) */
  303. char *CAfile; /* certificate to verify peer against */
  304. const char *CRLfile; /* CRL to check certificate revocation */
  305. const char *issuercert;/* optional issuer certificate filename */
  306. char *random_file; /* path to file containing "random" data */
  307. char *egdsocket; /* path to file containing the EGD daemon socket */
  308. char *cipher_list; /* list of ciphers to use */
  309. size_t max_ssl_sessions; /* SSL session id cache size */
  310. curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
  311. void *fsslctxp; /* parameter for call back */
  312. bool sessionid; /* cache session IDs or not */
  313. bool certinfo; /* gather lots of certificate info */
  314. #ifdef USE_TLS_SRP
  315. char *username; /* TLS username (for, e.g., SRP) */
  316. char *password; /* TLS password (for, e.g., SRP) */
  317. enum CURL_TLSAUTH authtype; /* TLS authentication type (default SRP) */
  318. #endif
  319. };
  320. /* information stored about one single SSL session */
  321. struct curl_ssl_session {
  322. char *name; /* host name for which this ID was used */
  323. void *sessionid; /* as returned from the SSL layer */
  324. size_t idsize; /* if known, otherwise 0 */
  325. long age; /* just a number, the higher the more recent */
  326. unsigned short remote_port; /* remote port to connect to */
  327. struct ssl_config_data ssl_config; /* setup for this session */
  328. };
  329. /* Struct used for Digest challenge-response authentication */
  330. struct digestdata {
  331. char *nonce;
  332. char *cnonce;
  333. char *realm;
  334. int algo;
  335. bool stale; /* set true for re-negotiation */
  336. char *opaque;
  337. char *qop;
  338. char *algorithm;
  339. int nc; /* nounce count */
  340. };
  341. typedef enum {
  342. NTLMSTATE_NONE,
  343. NTLMSTATE_TYPE1,
  344. NTLMSTATE_TYPE2,
  345. NTLMSTATE_TYPE3,
  346. NTLMSTATE_LAST
  347. } curlntlm;
  348. #ifdef USE_WINDOWS_SSPI
  349. #include "curl_sspi.h"
  350. #endif
  351. #if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
  352. #include <iconv.h>
  353. #endif
  354. /* Struct used for NTLM challenge-response authentication */
  355. struct ntlmdata {
  356. curlntlm state;
  357. #ifdef USE_WINDOWS_SSPI
  358. CredHandle handle;
  359. CtxtHandle c_handle;
  360. SEC_WINNT_AUTH_IDENTITY identity;
  361. SEC_WINNT_AUTH_IDENTITY *p_identity;
  362. int has_handles;
  363. void *type_2;
  364. unsigned long n_type_2;
  365. #else
  366. unsigned int flags;
  367. unsigned char nonce[8];
  368. #endif
  369. };
  370. #ifdef USE_HTTP_NEGOTIATE
  371. struct negotiatedata {
  372. /* when doing Negotiate we first need to receive an auth token and then we
  373. need to send our header */
  374. enum { GSS_AUTHNONE, GSS_AUTHRECV, GSS_AUTHSENT } state;
  375. bool gss; /* Whether we're processing GSS-Negotiate or Negotiate */
  376. const char* protocol; /* "GSS-Negotiate" or "Negotiate" */
  377. #ifdef HAVE_GSSAPI
  378. OM_uint32 status;
  379. gss_ctx_id_t context;
  380. gss_name_t server_name;
  381. gss_buffer_desc output_token;
  382. #else
  383. #ifdef USE_WINDOWS_SSPI
  384. DWORD status;
  385. CtxtHandle *context;
  386. CredHandle *credentials;
  387. char server_name[1024];
  388. size_t max_token_length;
  389. BYTE *output_token;
  390. size_t output_token_length;
  391. #endif
  392. #endif
  393. };
  394. #endif
  395. /*
  396. * Boolean values that concerns this connection.
  397. */
  398. struct ConnectBits {
  399. bool close; /* if set, we close the connection after this request */
  400. bool reuse; /* if set, this is a re-used connection */
  401. bool proxy; /* if set, this transfer is done through a proxy - any type */
  402. bool httpproxy; /* if set, this transfer is done through a http proxy */
  403. bool user_passwd; /* do we use user+password for this connection? */
  404. bool proxy_user_passwd; /* user+password for the proxy? */
  405. bool ipv6_ip; /* we communicate with a remote site specified with pure IPv6
  406. IP address */
  407. bool ipv6; /* we communicate with a site using an IPv6 address */
  408. bool do_more; /* this is set TRUE if the ->curl_do_more() function is
  409. supposed to be called, after ->curl_do() */
  410. bool tcpconnect[2]; /* the TCP layer (or similar) is connected, this is set
  411. the first time on the first connect function call */
  412. bool protoconnstart;/* the protocol layer has STARTED its operation after
  413. the TCP layer connect */
  414. bool retry; /* this connection is about to get closed and then
  415. re-attempted at another connection. */
  416. bool tunnel_proxy; /* if CONNECT is used to "tunnel" through the proxy.
  417. This is implicit when SSL-protocols are used through
  418. proxies, but can also be enabled explicitly by
  419. apps */
  420. bool authneg; /* TRUE when the auth phase has started, which means
  421. that we are creating a request with an auth header,
  422. but it is not the final request in the auth
  423. negotiation. */
  424. bool rewindaftersend;/* TRUE when the sending couldn't be stopped even
  425. though it will be discarded. When the whole send
  426. operation is done, we must call the data rewind
  427. callback. */
  428. bool ftp_use_epsv; /* As set with CURLOPT_FTP_USE_EPSV, but if we find out
  429. EPSV doesn't work we disable it for the forthcoming
  430. requests */
  431. bool ftp_use_eprt; /* As set with CURLOPT_FTP_USE_EPRT, but if we find out
  432. EPRT doesn't work we disable it for the forthcoming
  433. requests */
  434. bool netrc; /* name+password provided by netrc */
  435. bool userpwd_in_url; /* name+password found in url */
  436. bool done; /* set to FALSE when Curl_do() is called and set to TRUE
  437. when Curl_done() is called, to prevent Curl_done() to
  438. get invoked twice when the multi interface is
  439. used. */
  440. bool stream_was_rewound; /* Indicates that the stream was rewound after a
  441. request read past the end of its response byte
  442. boundary */
  443. bool proxy_connect_closed; /* set true if a proxy disconnected the
  444. connection in a CONNECT request with auth, so
  445. that libcurl should reconnect and continue. */
  446. bool bound; /* set true if bind() has already been done on this socket/
  447. connection */
  448. bool type_set; /* type= was used in the URL */
  449. };
  450. struct hostname {
  451. char *rawalloc; /* allocated "raw" version of the name */
  452. char *encalloc; /* allocated IDN-encoded version of the name */
  453. char *name; /* name to use internally, might be encoded, might be raw */
  454. const char *dispname; /* name to display, as 'name' might be encoded */
  455. };
  456. /*
  457. * Flags on the keepon member of the Curl_transfer_keeper
  458. */
  459. #define KEEP_NONE 0
  460. #define KEEP_RECV (1<<0) /* there is or may be data to read */
  461. #define KEEP_SEND (1<<1) /* there is or may be data to write */
  462. #define KEEP_RECV_HOLD (1<<2) /* when set, no reading should be done but there
  463. might still be data to read */
  464. #define KEEP_SEND_HOLD (1<<3) /* when set, no writing should be done but there
  465. might still be data to write */
  466. #define KEEP_RECV_PAUSE (1<<4) /* reading is paused */
  467. #define KEEP_SEND_PAUSE (1<<5) /* writing is paused */
  468. #define KEEP_RECVBITS (KEEP_RECV | KEEP_RECV_HOLD | KEEP_RECV_PAUSE)
  469. #define KEEP_SENDBITS (KEEP_SEND | KEEP_SEND_HOLD | KEEP_SEND_PAUSE)
  470. #ifdef HAVE_LIBZ
  471. typedef enum {
  472. ZLIB_UNINIT, /* uninitialized */
  473. ZLIB_INIT, /* initialized */
  474. ZLIB_GZIP_HEADER, /* reading gzip header */
  475. ZLIB_GZIP_INFLATING, /* inflating gzip stream */
  476. ZLIB_INIT_GZIP /* initialized in transparent gzip mode */
  477. } zlibInitState;
  478. #endif
  479. #ifdef CURLRES_ASYNCH
  480. struct Curl_async {
  481. char *hostname;
  482. int port;
  483. struct Curl_dns_entry *dns;
  484. bool done; /* set TRUE when the lookup is complete */
  485. int status; /* if done is TRUE, this is the status from the callback */
  486. void *os_specific; /* 'struct thread_data' for Windows */
  487. };
  488. #endif
  489. #define FIRSTSOCKET 0
  490. #define SECONDARYSOCKET 1
  491. /* These function pointer types are here only to allow easier typecasting
  492. within the source when we need to cast between data pointers (such as NULL)
  493. and function pointers. */
  494. typedef CURLcode (*Curl_do_more_func)(struct connectdata *, bool *);
  495. typedef CURLcode (*Curl_done_func)(struct connectdata *, CURLcode, bool);
  496. enum expect100 {
  497. EXP100_SEND_DATA, /* enough waiting, just send the body now */
  498. EXP100_AWAITING_CONTINUE, /* waiting for the 100 Continue header */
  499. EXP100_SENDING_REQUEST, /* still sending the request but will wait for
  500. the 100 header once done with the request */
  501. EXP100_FAILED /* used on 417 Expectation Failed */
  502. };
  503. /*
  504. * Request specific data in the easy handle (SessionHandle). Previously,
  505. * these members were on the connectdata struct but since a conn struct may
  506. * now be shared between different SessionHandles, we store connection-specific
  507. * data here. This struct only keeps stuff that's interesting for *this*
  508. * request, as it will be cleared between multiple ones
  509. */
  510. struct SingleRequest {
  511. curl_off_t size; /* -1 if unknown at this point */
  512. curl_off_t *bytecountp; /* return number of bytes read or NULL */
  513. curl_off_t maxdownload; /* in bytes, the maximum amount of data to fetch,
  514. -1 means unlimited */
  515. curl_off_t *writebytecountp; /* return number of bytes written or NULL */
  516. curl_off_t bytecount; /* total number of bytes read */
  517. curl_off_t writebytecount; /* number of bytes written */
  518. long headerbytecount; /* only count received headers */
  519. long deductheadercount; /* this amount of bytes doesn't count when we check
  520. if anything has been transferred at the end of a
  521. connection. We use this counter to make only a
  522. 100 reply (without a following second response
  523. code) result in a CURLE_GOT_NOTHING error code */
  524. struct timeval start; /* transfer started at this time */
  525. struct timeval now; /* current time */
  526. bool header; /* incoming data has HTTP header */
  527. enum {
  528. HEADER_NORMAL, /* no bad header at all */
  529. HEADER_PARTHEADER, /* part of the chunk is a bad header, the rest
  530. is normal data */
  531. HEADER_ALLBAD /* all was believed to be header */
  532. } badheader; /* the header was deemed bad and will be
  533. written as body */
  534. int headerline; /* counts header lines to better track the
  535. first one */
  536. char *hbufp; /* points at *end* of header line */
  537. size_t hbuflen;
  538. char *str; /* within buf */
  539. char *str_start; /* within buf */
  540. char *end_ptr; /* within buf */
  541. char *p; /* within headerbuff */
  542. bool content_range; /* set TRUE if Content-Range: was found */
  543. curl_off_t offset; /* possible resume offset read from the
  544. Content-Range: header */
  545. int httpcode; /* error code from the 'HTTP/1.? XXX' or
  546. 'RTSP/1.? XXX' line */
  547. struct timeval start100; /* time stamp to wait for the 100 code from */
  548. enum expect100 exp100; /* expect 100 continue state */
  549. int auto_decoding; /* What content encoding. sec 3.5, RFC2616. */
  550. #define IDENTITY 0 /* No encoding */
  551. #define DEFLATE 1 /* zlib deflate [RFC 1950 & 1951] */
  552. #define GZIP 2 /* gzip algorithm [RFC 1952] */
  553. #define COMPRESS 3 /* Not handled, added for completeness */
  554. #ifdef HAVE_LIBZ
  555. zlibInitState zlib_init; /* possible zlib init state;
  556. undefined if Content-Encoding header. */
  557. z_stream z; /* State structure for zlib. */
  558. #endif
  559. time_t timeofdoc;
  560. long bodywrites;
  561. char *buf;
  562. char *uploadbuf;
  563. curl_socket_t maxfd;
  564. int keepon;
  565. bool upload_done; /* set to TRUE when doing chunked transfer-encoding upload
  566. and we're uploading the last chunk */
  567. bool ignorebody; /* we read a response-body but we ignore it! */
  568. bool ignorecl; /* This HTTP response has no body so we ignore the Content-
  569. Length: header */
  570. char *location; /* This points to an allocated version of the Location:
  571. header data */
  572. char *newurl; /* Set to the new URL to use when a redirect or a retry is
  573. wanted */
  574. /* 'upload_present' is used to keep a byte counter of how much data there is
  575. still left in the buffer, aimed for upload. */
  576. ssize_t upload_present;
  577. /* 'upload_fromhere' is used as a read-pointer when we uploaded parts of a
  578. buffer, so the next read should read from where this pointer points to,
  579. and the 'upload_present' contains the number of bytes available at this
  580. position */
  581. char *upload_fromhere;
  582. bool chunk; /* if set, this is a chunked transfer-encoding */
  583. bool upload_chunky; /* set TRUE if we are doing chunked transfer-encoding
  584. on upload */
  585. bool getheader; /* TRUE if header parsing is wanted */
  586. bool forbidchunk; /* used only to explicitly forbid chunk-upload for
  587. specific upload buffers. See readmoredata() in
  588. http.c for details. */
  589. };
  590. /*
  591. * Specific protocol handler.
  592. */
  593. struct Curl_handler {
  594. const char * scheme; /* URL scheme name. */
  595. /* Complement to setup_connection_internals(). */
  596. CURLcode (*setup_connection)(struct connectdata *);
  597. /* These two functions MUST be set to be protocol dependent */
  598. CURLcode (*do_it)(struct connectdata *, bool *done);
  599. Curl_done_func done;
  600. /* If the curl_do() function is better made in two halves, this
  601. * curl_do_more() function will be called afterwards, if set. For example
  602. * for doing the FTP stuff after the PASV/PORT command.
  603. */
  604. Curl_do_more_func do_more;
  605. /* This function *MAY* be set to a protocol-dependent function that is run
  606. * after the connect() and everything is done, as a step in the connection.
  607. * The 'done' pointer points to a bool that should be set to TRUE if the
  608. * function completes before return. If it doesn't complete, the caller
  609. * should call the curl_connecting() function until it is.
  610. */
  611. CURLcode (*connect_it)(struct connectdata *, bool *done);
  612. /* See above. Currently only used for FTP. */
  613. CURLcode (*connecting)(struct connectdata *, bool *done);
  614. CURLcode (*doing)(struct connectdata *, bool *done);
  615. /* Called from the multi interface during the PROTOCONNECT phase, and it
  616. should then return a proper fd set */
  617. int (*proto_getsock)(struct connectdata *conn,
  618. curl_socket_t *socks,
  619. int numsocks);
  620. /* Called from the multi interface during the DOING phase, and it should
  621. then return a proper fd set */
  622. int (*doing_getsock)(struct connectdata *conn,
  623. curl_socket_t *socks,
  624. int numsocks);
  625. /* Called from the multi interface during the DO_MORE phase, and it should
  626. then return a proper fd set */
  627. int (*domore_getsock)(struct connectdata *conn,
  628. curl_socket_t *socks,
  629. int numsocks);
  630. /* Called from the multi interface during the DO_DONE, PERFORM and
  631. WAITPERFORM phases, and it should then return a proper fd set. Not setting
  632. this will make libcurl use the generic default one. */
  633. int (*perform_getsock)(const struct connectdata *conn,
  634. curl_socket_t *socks,
  635. int numsocks);
  636. /* This function *MAY* be set to a protocol-dependent function that is run
  637. * by the curl_disconnect(), as a step in the disconnection. If the handler
  638. * is called because the connection has been considered dead, dead_connection
  639. * is set to TRUE.
  640. */
  641. CURLcode (*disconnect)(struct connectdata *, bool dead_connection);
  642. /* If used, this function gets called from transfer.c:readwrite_data() to
  643. allow the protocol to do extra reads/writes */
  644. CURLcode (*readwrite)(struct SessionHandle *data, struct connectdata *conn,
  645. ssize_t *nread, bool *readmore);
  646. long defport; /* Default port. */
  647. unsigned int protocol; /* See CURLPROTO_* */
  648. unsigned int flags; /* Extra particular characteristics, see PROTOPT_* */
  649. };
  650. #define PROTOPT_NONE 0 /* nothing extra */
  651. #define PROTOPT_SSL (1<<0) /* uses SSL */
  652. #define PROTOPT_DUAL (1<<1) /* this protocol uses two connections */
  653. #define PROTOPT_CLOSEACTION (1<<2) /* need action before socket close */
  654. /* some protocols will have to call the underlying functions without regard to
  655. what exact state the socket signals. IE even if the socket says "readable",
  656. the send function might need to be called while uploading, or vice versa.
  657. */
  658. #define PROTOPT_DIRLOCK (1<<3)
  659. #define PROTOPT_NONETWORK (1<<4) /* protocol doesn't use the network! */
  660. #define PROTOPT_NEEDSPWD (1<<5) /* needs a password, and if none is set it
  661. gets a default */
  662. #define PROTOPT_NOURLQUERY (1<<6) /* protocol can't handle
  663. url query strings (?foo=bar) ! */
  664. /* return the count of bytes sent, or -1 on error */
  665. typedef ssize_t (Curl_send)(struct connectdata *conn, /* connection data */
  666. int sockindex, /* socketindex */
  667. const void *buf, /* data to write */
  668. size_t len, /* max amount to write */
  669. CURLcode *err); /* error to return */
  670. /* return the count of bytes read, or -1 on error */
  671. typedef ssize_t (Curl_recv)(struct connectdata *conn, /* connection data */
  672. int sockindex, /* socketindex */
  673. char *buf, /* store data here */
  674. size_t len, /* max amount to read */
  675. CURLcode *err); /* error to return */
  676. /*
  677. * The connectdata struct contains all fields and variables that should be
  678. * unique for an entire connection.
  679. */
  680. struct connectdata {
  681. /* 'data' is the CURRENT SessionHandle using this connection -- take great
  682. caution that this might very well vary between different times this
  683. connection is used! */
  684. struct SessionHandle *data;
  685. /* chunk is for HTTP chunked encoding, but is in the general connectdata
  686. struct only because we can do just about any protocol through a HTTP proxy
  687. and a HTTP proxy may in fact respond using chunked encoding */
  688. struct Curl_chunker chunk;
  689. curl_closesocket_callback fclosesocket; /* function closing the socket(s) */
  690. void *closesocket_client;
  691. bool inuse; /* This is a marker for the connection cache logic. If this is
  692. TRUE this handle is being used by an easy handle and cannot
  693. be used by any other easy handle without careful
  694. consideration (== only for pipelining). */
  695. /**** Fields set when inited and not modified again */
  696. long connectindex; /* what index in the connection cache connects index this
  697. particular struct has */
  698. /* 'dns_entry' is the particular host we use. This points to an entry in the
  699. DNS cache and it will not get pruned while locked. It gets unlocked in
  700. Curl_done(). This entry will be NULL if the connection is re-used as then
  701. there is no name resolve done. */
  702. struct Curl_dns_entry *dns_entry;
  703. /* 'ip_addr' is the particular IP we connected to. It points to a struct
  704. within the DNS cache, so this pointer is only valid as long as the DNS
  705. cache entry remains locked. It gets unlocked in Curl_done() */
  706. Curl_addrinfo *ip_addr;
  707. /* 'ip_addr_str' is the ip_addr data as a human readable string.
  708. It remains available as long as the connection does, which is longer than
  709. the ip_addr itself. */
  710. char ip_addr_str[MAX_IPADR_LEN];
  711. unsigned int scope; /* address scope for IPv6 */
  712. int socktype; /* SOCK_STREAM or SOCK_DGRAM */
  713. struct hostname host;
  714. struct hostname proxy;
  715. long port; /* which port to use locally */
  716. unsigned short remote_port; /* what remote port to connect to,
  717. not the proxy port! */
  718. /* 'primary_ip' and 'primary_port' get filled with peer's numerical
  719. ip address and port number whenever an outgoing connection is
  720. *attempted* from the primary socket to a remote address. When more
  721. than one address is tried for a connection these will hold data
  722. for the last attempt. When the connection is actually established
  723. these are updated with data which comes directly from the socket. */
  724. char primary_ip[MAX_IPADR_LEN];
  725. long primary_port;
  726. /* 'local_ip' and 'local_port' get filled with local's numerical
  727. ip address and port number whenever an outgoing connection is
  728. **established** from the primary socket to a remote address. */
  729. char local_ip[MAX_IPADR_LEN];
  730. long local_port;
  731. char *user; /* user name string, allocated */
  732. char *passwd; /* password string, allocated */
  733. char *proxyuser; /* proxy user name string, allocated */
  734. char *proxypasswd; /* proxy password string, allocated */
  735. curl_proxytype proxytype; /* what kind of proxy that is in use */
  736. int httpversion; /* the HTTP version*10 reported by the server */
  737. int rtspversion; /* the RTSP version*10 reported by the server */
  738. struct timeval now; /* "current" time */
  739. struct timeval created; /* creation time */
  740. curl_socket_t sock[2]; /* two sockets, the second is used for the data
  741. transfer when doing FTP */
  742. bool sock_accepted[2]; /* TRUE if the socket on this index was created with
  743. accept() */
  744. Curl_recv *recv[2];
  745. Curl_send *send[2];
  746. struct ssl_connect_data ssl[2]; /* this is for ssl-stuff */
  747. struct ssl_config_data ssl_config;
  748. struct ConnectBits bits; /* various state-flags for this connection */
  749. /* connecttime: when connect() is called on the current IP address. Used to
  750. be able to track when to move on to try next IP - but only when the multi
  751. interface is used. */
  752. struct timeval connecttime;
  753. /* The two fields below get set in Curl_connecthost */
  754. int num_addr; /* number of addresses to try to connect to */
  755. long timeoutms_per_addr; /* how long time in milliseconds to spend on
  756. trying to connect to each IP address */
  757. const struct Curl_handler *handler; /* Connection's protocol handler */
  758. const struct Curl_handler *given; /* The protocol first given */
  759. long ip_version; /* copied from the SessionHandle at creation time */
  760. /**** curl_get() phase fields */
  761. curl_socket_t sockfd; /* socket to read from or CURL_SOCKET_BAD */
  762. curl_socket_t writesockfd; /* socket to write to, it may very
  763. well be the same we read from.
  764. CURL_SOCKET_BAD disables */
  765. /** Dynamicly allocated strings, MUST be freed before this **/
  766. /** struct is killed. **/
  767. struct dynamically_allocated_data {
  768. char *proxyuserpwd;
  769. char *uagent;
  770. char *accept_encoding;
  771. char *userpwd;
  772. char *rangeline;
  773. char *ref;
  774. char *host;
  775. char *cookiehost;
  776. char *rtsp_transport;
  777. char *te; /* TE: request header */
  778. } allocptr;
  779. int sec_complete; /* if kerberos is enabled for this connection */
  780. #if defined(HAVE_KRB4) || defined(HAVE_GSSAPI)
  781. enum protection_level command_prot;
  782. enum protection_level data_prot;
  783. enum protection_level request_data_prot;
  784. size_t buffer_size;
  785. struct krb4buffer in_buffer;
  786. void *app_data;
  787. const struct Curl_sec_client_mech *mech;
  788. struct sockaddr_in local_addr;
  789. #endif
  790. /* the two following *_inuse fields are only flags, not counters in any way.
  791. If TRUE it means the channel is in use, and if FALSE it means the channel
  792. is up for grabs by one. */
  793. bool readchannel_inuse; /* whether the read channel is in use by an easy
  794. handle */
  795. bool writechannel_inuse; /* whether the write channel is in use by an easy
  796. handle */
  797. bool server_supports_pipelining; /* TRUE if server supports pipelining,
  798. set after first response */
  799. struct curl_llist *send_pipe; /* List of handles waiting to
  800. send on this pipeline */
  801. struct curl_llist *recv_pipe; /* List of handles waiting to read
  802. their responses on this pipeline */
  803. struct curl_llist *pend_pipe; /* List of pending handles on
  804. this pipeline */
  805. struct curl_llist *done_pipe; /* Handles that are finished, but
  806. still reference this connectdata */
  807. #define MAX_PIPELINE_LENGTH 5
  808. char* master_buffer; /* The master buffer allocated on-demand;
  809. used for pipelining. */
  810. size_t read_pos; /* Current read position in the master buffer */
  811. size_t buf_len; /* Length of the buffer?? */
  812. curl_seek_callback seek_func; /* function that seeks the input */
  813. void *seek_client; /* pointer to pass to the seek() above */
  814. /*************** Request - specific items ************/
  815. /* previously this was in the urldata struct */
  816. curl_read_callback fread_func; /* function that reads the input */
  817. void *fread_in; /* pointer to pass to the fread() above */
  818. struct ntlmdata ntlm; /* NTLM differs from other authentication schemes
  819. because it authenticates connections, not
  820. single requests! */
  821. struct ntlmdata proxyntlm; /* NTLM data for proxy */
  822. #if defined(USE_NTLM) && defined(NTLM_WB_ENABLED)
  823. /* used for communication with Samba's winbind daemon helper ntlm_auth */
  824. curl_socket_t ntlm_auth_hlpr_socket;
  825. pid_t ntlm_auth_hlpr_pid;
  826. char* challenge_header;
  827. char* response_header;
  828. #endif
  829. char syserr_buf [256]; /* buffer for Curl_strerror() */
  830. #ifdef CURLRES_ASYNCH
  831. /* data used for the asynch name resolve callback */
  832. struct Curl_async async;
  833. #endif
  834. /* These three are used for chunked-encoding trailer support */
  835. char *trailer; /* allocated buffer to store trailer in */
  836. int trlMax; /* allocated buffer size */
  837. int trlPos; /* index of where to store data */
  838. union {
  839. struct ftp_conn ftpc;
  840. struct ssh_conn sshc;
  841. struct tftp_state_data *tftpc;
  842. struct imap_conn imapc;
  843. struct pop3_conn pop3c;
  844. struct smtp_conn smtpc;
  845. struct rtsp_conn rtspc;
  846. void *generic;
  847. } proto;
  848. int cselect_bits; /* bitmask of socket events */
  849. int waitfor; /* current READ/WRITE bits to wait for */
  850. #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
  851. int socks5_gssapi_enctype;
  852. #endif
  853. long verifypeer;
  854. long verifyhost;
  855. /* When this connection is created, store the conditions for the local end
  856. bind. This is stored before the actual bind and before any connection is
  857. made and will serve the purpose of being used for comparison reasons so
  858. that subsequent bound-requested connections aren't accidentally re-using
  859. wrong connections. */
  860. char *localdev;
  861. unsigned short localport;
  862. int localportrange;
  863. /* tunnel as in tunnel through a HTTP proxy with CONNECT */
  864. enum {
  865. TUNNEL_INIT, /* init/default/no tunnel state */
  866. TUNNEL_CONNECT, /* CONNECT has been sent off */
  867. TUNNEL_COMPLETE /* CONNECT response received completely */
  868. } tunnel_state[2]; /* two separate ones to allow FTP */
  869. };
  870. /* The end of connectdata. */
  871. /*
  872. * Struct to keep statistical and informational data.
  873. */
  874. struct PureInfo {
  875. int httpcode; /* Recent HTTP, FTP, or RTSP response code */
  876. int httpproxycode; /* response code from proxy when received separate */
  877. int httpversion; /* the http version number X.Y = X*10+Y */
  878. long filetime; /* If requested, this is might get set. Set to -1 if the time
  879. was unretrievable. We cannot have this of type time_t,
  880. since time_t is unsigned on several platforms such as
  881. OpenVMS. */
  882. bool timecond; /* set to TRUE if the time condition didn't match, which
  883. thus made the document NOT get fetched */
  884. long header_size; /* size of read header(s) in bytes */
  885. long request_size; /* the amount of bytes sent in the request(s) */
  886. unsigned long proxyauthavail; /* what proxy auth types were announced */
  887. unsigned long httpauthavail; /* what host auth types were announced */
  888. long numconnects; /* how many new connection did libcurl created */
  889. char *contenttype; /* the content type of the object */
  890. char *wouldredirect; /* URL this would've been redirected to if asked to */
  891. /* PureInfo members 'conn_primary_ip', 'conn_primary_port', 'conn_local_ip'
  892. and, 'conn_local_port' are copied over from the connectdata struct in
  893. order to allow curl_easy_getinfo() to return this information even when
  894. the session handle is no longer associated with a connection, and also
  895. allow curl_easy_reset() to clear this information from the session handle
  896. without disturbing information which is still alive, and that might be
  897. reused, in the connection cache. */
  898. char conn_primary_ip[MAX_IPADR_LEN];
  899. long conn_primary_port;
  900. char conn_local_ip[MAX_IPADR_LEN];
  901. long conn_local_port;
  902. struct curl_certinfo certs; /* info about the certs, only populated in
  903. OpenSSL builds. Asked for with
  904. CURLOPT_CERTINFO / CURLINFO_CERTINFO */
  905. };
  906. struct Progress {
  907. long lastshow; /* time() of the last displayed progress meter or NULL to
  908. force redraw at next call */
  909. curl_off_t size_dl; /* total expected size */
  910. curl_off_t size_ul; /* total expected size */
  911. curl_off_t downloaded; /* transferred so far */
  912. curl_off_t uploaded; /* transferred so far */
  913. curl_off_t current_speed; /* uses the currently fastest transfer */
  914. bool callback; /* set when progress callback is used */
  915. int width; /* screen width at download start */
  916. int flags; /* see progress.h */
  917. double timespent;
  918. curl_off_t dlspeed;
  919. curl_off_t ulspeed;
  920. double t_nslookup;
  921. double t_connect;
  922. double t_appconnect;
  923. double t_pretransfer;
  924. double t_starttransfer;
  925. double t_redirect;
  926. struct timeval start;
  927. struct timeval t_startsingle;
  928. struct timeval t_acceptdata;
  929. #define CURR_TIME (5+1) /* 6 entries for 5 seconds */
  930. curl_off_t speeder[ CURR_TIME ];
  931. struct timeval speeder_time[ CURR_TIME ];
  932. int speeder_c;
  933. };
  934. typedef enum {
  935. HTTPREQ_NONE, /* first in list */
  936. HTTPREQ_GET,
  937. HTTPREQ_POST,
  938. HTTPREQ_POST_FORM, /* we make a difference internally */
  939. HTTPREQ_PUT,
  940. HTTPREQ_HEAD,
  941. HTTPREQ_CUSTOM,
  942. HTTPREQ_LAST /* last in list */
  943. } Curl_HttpReq;
  944. typedef enum {
  945. RTSPREQ_NONE, /* first in list */
  946. RTSPREQ_OPTIONS,
  947. RTSPREQ_DESCRIBE,
  948. RTSPREQ_ANNOUNCE,
  949. RTSPREQ_SETUP,
  950. RTSPREQ_PLAY,
  951. RTSPREQ_PAUSE,
  952. RTSPREQ_TEARDOWN,
  953. RTSPREQ_GET_PARAMETER,
  954. RTSPREQ_SET_PARAMETER,
  955. RTSPREQ_RECORD,
  956. RTSPREQ_RECEIVE,
  957. RTSPREQ_LAST /* last in list */
  958. } Curl_RtspReq;
  959. /*
  960. * Values that are generated, temporary or calculated internally for a
  961. * "session handle" must be defined within the 'struct UrlState'. This struct
  962. * will be used within the SessionHandle struct. When the 'SessionHandle'
  963. * struct is cloned, this data MUST NOT be copied.
  964. *
  965. * Remember that any "state" information goes globally for the curl handle.
  966. * Session-data MUST be put in the connectdata struct and here. */
  967. #define MAX_CURL_USER_LENGTH 256
  968. #define MAX_CURL_PASSWORD_LENGTH 256
  969. #define MAX_CURL_USER_LENGTH_TXT "255"
  970. #define MAX_CURL_PASSWORD_LENGTH_TXT "255"
  971. struct auth {
  972. unsigned long want; /* Bitmask set to the authentication methods wanted by
  973. app (with CURLOPT_HTTPAUTH or CURLOPT_PROXYAUTH). */
  974. unsigned long picked;
  975. unsigned long avail; /* Bitmask for what the server reports to support for
  976. this resource */
  977. bool done; /* TRUE when the auth phase is done and ready to do the *actual*
  978. request */
  979. bool multi; /* TRUE if this is not yet authenticated but within the auth
  980. multipass negotiation */
  981. bool iestyle; /* TRUE if digest should be done IE-style or FALSE if it should
  982. be RFC compliant */
  983. };
  984. struct conncache {
  985. /* 'connects' will be an allocated array with pointers. If the pointer is
  986. set, it holds an allocated connection. */
  987. struct connectdata **connects;
  988. long num; /* number of entries of the 'connects' array */
  989. enum {
  990. CONNCACHE_PRIVATE, /* used for an easy handle alone */
  991. CONNCACHE_MULTI /* shared within a multi handle */
  992. } type;
  993. };
  994. struct UrlState {
  995. enum {
  996. Curl_if_none,
  997. Curl_if_easy,
  998. Curl_if_multi
  999. } used_interface;
  1000. struct conncache *connc; /* points to the connection cache this handle
  1001. uses */
  1002. /* buffers to store authentication data in, as parsed from input options */
  1003. struct timeval keeps_speed; /* for the progress meter really */
  1004. long lastconnect; /* index of most recent connect or -1 if undefined */
  1005. char *headerbuff; /* allocated buffer to store headers in */
  1006. size_t headersize; /* size of the allocation */
  1007. char buffer[BUFSIZE+1]; /* download buffer */
  1008. char uploadbuffer[BUFSIZE+1]; /* upload buffer */
  1009. curl_off_t current_speed; /* the ProgressShow() funcion sets this,
  1010. bytes / second */
  1011. bool this_is_a_follow; /* this is a followed Location: request */
  1012. char *first_host; /* if set, this should be the host name that we will
  1013. sent authorization to, no else. Used to make Location:
  1014. following not keep sending user+password... This is
  1015. strdup() data.
  1016. */
  1017. struct curl_ssl_session *session; /* array of 'max_ssl_sessions' size */
  1018. long sessionage; /* number of the most recent session */
  1019. char *tempwrite; /* allocated buffer to keep data in when a write
  1020. callback returns to make the connection paused */
  1021. size_t tempwritesize; /* size of the 'tempwrite' allocated buffer */
  1022. int tempwritetype; /* type of the 'tempwrite' buffer as a bitmask that is
  1023. used with Curl_client_write() */
  1024. char *scratch; /* huge buffer[BUFSIZE*2] when doing upload CRLF replacing */
  1025. bool errorbuf; /* Set to TRUE if the error buffer is already filled in.
  1026. This must be set to FALSE every time _easy_perform() is
  1027. called. */
  1028. int os_errno; /* filled in with errno whenever an error occurs */
  1029. #ifdef HAVE_SIGNAL
  1030. /* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */
  1031. void (*prev_signal)(int sig);
  1032. #endif
  1033. bool allow_port; /* Is set.use_port allowed to take effect or not. This
  1034. is always set TRUE when curl_easy_perform() is called. */
  1035. struct digestdata digest; /* state data for host Digest auth */
  1036. struct digestdata proxydigest; /* state data for proxy Digest auth */
  1037. #ifdef USE_HTTP_NEGOTIATE
  1038. struct negotiatedata negotiate; /* state data for host Negotiate auth */
  1039. struct negotiatedata proxyneg; /* state data for proxy Negotiate auth */
  1040. #endif
  1041. struct auth authhost; /* auth details for host */
  1042. struct auth authproxy; /* auth details for proxy */
  1043. bool authproblem; /* TRUE if there's some problem authenticating */
  1044. void *resolver; /* resolver state, if it is used in the URL state -
  1045. ares_channel f.e. */
  1046. #if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
  1047. ENGINE *engine;
  1048. #endif /* USE_SSLEAY */
  1049. struct timeval expiretime; /* set this with Curl_expire() only */
  1050. struct Curl_tree timenode; /* for the splay stuff */
  1051. struct curl_llist *timeoutlist; /* list of pending timeouts */
  1052. /* a place to store the most recently set FTP entrypath */
  1053. char *most_recent_ftp_entrypath;
  1054. /* set after initial USER failure, to prevent an authentication loop */
  1055. bool ftp_trying_alternative;
  1056. int httpversion; /* the lowest HTTP version*10 reported by any server
  1057. involved in this request */
  1058. bool expect100header; /* TRUE if we added Expect: 100-continue */
  1059. bool pipe_broke; /* TRUE if the connection we were pipelined on broke
  1060. and we need to restart from the beginning */
  1061. #if !defined(WIN32) && !defined(MSDOS) && !defined(__EMX__) && \
  1062. !defined(__SYMBIAN32__)
  1063. /* do FTP line-end conversions on most platforms */
  1064. #define CURL_DO_LINEEND_CONV
  1065. /* for FTP downloads: track CRLF sequences that span blocks */
  1066. bool prev_block_had_trailing_cr;
  1067. /* for FTP downloads: how many CRLFs did we converted to LFs? */
  1068. curl_off_t crlf_conversions;
  1069. #endif
  1070. /* If set to non-NULL, there's a connection in a shared connection cache
  1071. that uses this handle so we can't kill this SessionHandle just yet but
  1072. must keep it around and add it to the list of handles to kill once all
  1073. its connections are gone */
  1074. void *shared_conn;
  1075. bool closed; /* set to TRUE when curl_easy_cleanup() has been called on this
  1076. handle, but it is kept around as mentioned for
  1077. shared_conn */
  1078. char *pathbuffer;/* allocated buffer to store the URL's path part in */
  1079. char *path; /* path to use, points to somewhere within the pathbuffer
  1080. area */
  1081. bool slash_removed; /* set TRUE if the 'path' points to a path where the
  1082. initial URL slash separator has been taken off */
  1083. bool use_range;
  1084. bool rangestringalloc; /* the range string is malloc()'ed */
  1085. char *range; /* range, if used. See README for detailed specification on
  1086. this syntax. */
  1087. curl_off_t resume_from; /* continue [ftp] transfer from here */
  1088. /* This RTSP state information survives requests and connections */
  1089. long rtsp_next_client_CSeq; /* the session's next client CSeq */
  1090. long rtsp_next_server_CSeq; /* the session's next server CSeq */
  1091. long rtsp_CSeq_recv; /* most recent CSeq received */
  1092. /* Protocol specific data.
  1093. *
  1094. *************************************************************************
  1095. * Note that this data will be REMOVED after each request, so anything that
  1096. * should be kept/stored on a per-connection basis and thus live for the
  1097. * next request on the same connection MUST be put in the connectdata struct!
  1098. *************************************************************************/
  1099. union {
  1100. struct HTTP *http;
  1101. struct HTTP *https; /* alias, just for the sake of being more readable */
  1102. struct RTSP *rtsp;
  1103. struct FTP *ftp;
  1104. /* void *tftp; not used */
  1105. struct FILEPROTO *file;
  1106. void *telnet; /* private for telnet.c-eyes only */
  1107. void *generic;
  1108. struct SSHPROTO *ssh;
  1109. struct FTP *imap;
  1110. struct FTP *pop3;
  1111. struct FTP *smtp;
  1112. } proto;
  1113. /* current user of this SessionHandle instance, or NULL */
  1114. struct connectdata *current_conn;
  1115. /* if true, force SSL connection retry (workaround for certain servers) */
  1116. bool ssl_connect_retry;
  1117. };
  1118. /*
  1119. * This 'DynamicStatic' struct defines dynamic states that actually change
  1120. * values in the 'UserDefined' area, which MUST be taken into consideration
  1121. * if the UserDefined struct is cloned or similar. You can probably just
  1122. * copy these, but each one indicate a special action on other data.
  1123. */
  1124. struct DynamicStatic {
  1125. char *url; /* work URL, copied from UserDefined */
  1126. bool url_alloc; /* URL string is malloc()'ed */
  1127. char *referer; /* referer string */
  1128. bool referer_alloc; /* referer sting is malloc()ed */
  1129. struct curl_slist *cookielist; /* list of cookie files set by
  1130. curl_easy_setopt(COOKIEFILE) calls */
  1131. struct curl_slist *resolve; /* set to point to the set.resolve list when
  1132. this should be dealt with in pretransfer */
  1133. };
  1134. /*
  1135. * This 'UserDefined' struct must only contain data that is set once to go
  1136. * for many (perhaps) independent connections. Values that are generated or
  1137. * calculated internally for the "session handle" MUST be defined within the
  1138. * 'struct UrlState' instead. The only exceptions MUST note the changes in
  1139. * the 'DynamicStatic' struct.
  1140. * Character pointer fields point to dynamic storage, unless otherwise stated.
  1141. */
  1142. struct Curl_one_easy; /* declared and used only in multi.c */
  1143. struct Curl_multi; /* declared and used only in multi.c */
  1144. enum dupstring {
  1145. STRING_CERT, /* client certificate file name */
  1146. STRING_CERT_TYPE, /* format for certificate (default: PEM)*/
  1147. STRING_COOKIE, /* HTTP cookie string to send */
  1148. STRING_COOKIEJAR, /* dump all cookies to this file */
  1149. STRING_CUSTOMREQUEST, /* HTTP/FTP/RTSP request/method to use */
  1150. STRING_DEVICE, /* local network interface/address to use */
  1151. STRING_ENCODING, /* Accept-Encoding string */
  1152. STRING_FTP_ACCOUNT, /* ftp account data */
  1153. STRING_FTP_ALTERNATIVE_TO_USER, /* command to send if USER/PASS fails */
  1154. STRING_FTPPORT, /* port to send with the FTP PORT command */
  1155. STRING_KEY, /* private key file name */
  1156. STRING_KEY_PASSWD, /* plain text private key password */
  1157. STRING_KEY_TYPE, /* format for private key (default: PEM) */
  1158. STRING_KRB_LEVEL, /* krb security level */
  1159. STRING_NETRC_FILE, /* if not NULL, use this instead of trying to find
  1160. $HOME/.netrc */
  1161. STRING_COPYPOSTFIELDS, /* if POST, set the fields' values here */
  1162. STRING_PROXY, /* proxy to use */
  1163. STRING_SET_RANGE, /* range, if used */
  1164. STRING_SET_REFERER, /* custom string for the HTTP referer field */
  1165. STRING_SET_URL, /* what original URL to work on */
  1166. STRING_SSL_CAPATH, /* CA directory name (doesn't work on windows) */
  1167. STRING_SSL_CAFILE, /* certificate file to verify peer against */
  1168. STRING_SSL_CIPHER_LIST, /* list of ciphers to use */
  1169. STRING_SSL_EGDSOCKET, /* path to file containing the EGD daemon socket */
  1170. STRING_SSL_RANDOM_FILE, /* path to file containing "random" data */
  1171. STRING_USERAGENT, /* User-Agent string */
  1172. STRING_SSL_CRLFILE, /* crl file to check certificate */
  1173. STRING_SSL_ISSUERCERT, /* issuer cert file to check certificate */
  1174. STRING_USERNAME, /* <username>, if used */
  1175. STRING_PASSWORD, /* <password>, if used */
  1176. STRING_PROXYUSERNAME, /* Proxy <username>, if used */
  1177. STRING_PROXYPASSWORD, /* Proxy <password>, if used */
  1178. STRING_NOPROXY, /* List of hosts which should not use the proxy, if
  1179. used */
  1180. STRING_RTSP_SESSION_ID, /* Session ID to use */
  1181. STRING_RTSP_STREAM_URI, /* Stream URI for this request */
  1182. STRING_RTSP_TRANSPORT, /* Transport for this session */
  1183. #ifdef USE_LIBSSH2
  1184. STRING_SSH_PRIVATE_KEY, /* path to the private key file for auth */
  1185. STRING_SSH_PUBLIC_KEY, /* path to the public key file for auth */
  1186. STRING_SSH_HOST_PUBLIC_KEY_MD5, /* md5 of host public key in ascii hex */
  1187. STRING_SSH_KNOWNHOSTS, /* file name of knownhosts file */
  1188. #endif
  1189. #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
  1190. STRING_SOCKS5_GSSAPI_SERVICE, /* GSSAPI service name */
  1191. #endif
  1192. STRING_MAIL_FROM,
  1193. STRING_MAIL_AUTH,
  1194. #ifdef USE_TLS_SRP
  1195. STRING_TLSAUTH_USERNAME, /* TLS auth <username> */
  1196. STRING_TLSAUTH_PASSWORD, /* TLS auth <password> */
  1197. #endif
  1198. /* -- end of strings -- */
  1199. STRING_LAST /* not used, just an end-of-list marker */
  1200. };
  1201. struct UserDefined {
  1202. FILE *err; /* the stderr user data goes here */
  1203. void *debugdata; /* the data that will be passed to fdebug */
  1204. char *errorbuffer; /* (Static) store failure messages in here */
  1205. long proxyport; /* If non-zero, use this port number by default. If the
  1206. proxy string features a ":[port]" that one will override
  1207. this. */
  1208. void *out; /* the fetched file goes here */
  1209. void *in; /* the uploaded file is read from here */
  1210. void *writeheader; /* write the header to this if non-NULL */
  1211. void *rtp_out; /* write RTP to this if non-NULL */
  1212. long use_port; /* which port to use (when not using default) */
  1213. unsigned long httpauth; /* kind of HTTP authentication to use (bitmask) */
  1214. unsigned long proxyauth; /* kind of proxy authentication to use (bitmask) */
  1215. long followlocation; /* as in HTTP Location: */
  1216. long maxredirs; /* maximum no. of http(s) redirects to follow, set to -1
  1217. for infinity */
  1218. int keep_post; /* keep POSTs as POSTs after a 30x request; each
  1219. bit represents a request, from 301 to 303 */
  1220. bool free_referer; /* set TRUE if 'referer' points to a string we
  1221. allocated */
  1222. void *postfields; /* if POST, set the fields' values here */
  1223. curl_seek_callback seek_func; /* function that seeks the input */
  1224. curl_off_t postfieldsize; /* if POST, this might have a size to use instead
  1225. of strlen(), and then the data *may* be binary
  1226. (contain zero bytes) */
  1227. unsigned short localport; /* local port number to bind to */
  1228. int localportrange; /* number of additional port numbers to test in case the
  1229. 'localport' one can't be bind()ed */
  1230. curl_write_callback fwrite_func; /* function that stores the output */
  1231. curl_write_callback fwrite_header; /* function that stores headers */
  1232. curl_write_callback fwrite_rtp; /* function that stores interleaved RTP */
  1233. curl_read_callback fread_func; /* function that reads the input */
  1234. int is_fread_set; /* boolean, has read callback been set to non-NULL? */
  1235. int is_fwrite_set; /* boolean, has write callback been set to non-NULL? */
  1236. curl_progress_callback fprogress; /* function for progress information */
  1237. curl_debug_callback fdebug; /* function that write informational data */
  1238. curl_ioctl_callback ioctl_func; /* function for I/O control */
  1239. curl_sockopt_callback fsockopt; /* function for setting socket options */
  1240. void *sockopt_client; /* pointer to pass to the socket options callback */
  1241. curl_opensocket_callback fopensocket; /* function for checking/translating
  1242. the address and opening the
  1243. socket */
  1244. void* opensocket_client;
  1245. curl_closesocket_callback fclosesocket; /* function for closing the
  1246. socket */
  1247. void* closesocket_client;
  1248. void *seek_client; /* pointer to pass to the seek callback */
  1249. /* the 3 curl_conv_callback functions below are used on non-ASCII hosts */
  1250. /* function to convert from the network encoding: */
  1251. curl_conv_callback convfromnetwork;
  1252. /* function to convert to the network encoding: */
  1253. curl_conv_callback convtonetwork;
  1254. /* function to convert from UTF-8 encoding: */
  1255. curl_conv_callback convfromutf8;
  1256. void *progress_client; /* pointer to pass to the progress callback */
  1257. void *ioctl_client; /* pointer to pass to the ioctl callback */
  1258. long timeout; /* in milliseconds, 0 means no timeout */
  1259. long connecttimeout; /* in milliseconds, 0 means no timeout */
  1260. long accepttimeout; /* in milliseconds, 0 means no timeout */
  1261. long server_response_timeout; /* in milliseconds, 0 means no timeout */
  1262. long tftp_blksize ; /* in bytes, 0 means use default */
  1263. curl_off_t infilesize; /* size of file to upload, -1 means unknown */
  1264. long low_speed_limit; /* bytes/second */
  1265. long low_speed_time; /* number of seconds */
  1266. curl_off_t max_send_speed; /* high speed limit in bytes/second for upload */
  1267. curl_off_t max_recv_speed; /* high speed limit in bytes/second for
  1268. download */
  1269. curl_off_t set_resume_from; /* continue [ftp] transfer from here */
  1270. struct curl_slist *headers; /* linked list of extra headers */
  1271. struct curl_httppost *httppost; /* linked list of POST data */
  1272. bool cookiesession; /* new cookie session? */
  1273. bool crlf; /* convert crlf on ftp upload(?) */
  1274. struct curl_slist *quote; /* after connection is established */
  1275. struct curl_slist *postquote; /* after the transfer */
  1276. struct curl_slist *prequote; /* before the transfer, after type */
  1277. struct curl_slist *source_quote; /* 3rd party quote */
  1278. struct curl_slist *source_prequote; /* in 3rd party transfer mode - before
  1279. the transfer on source host */
  1280. struct curl_slist *source_postquote; /* in 3rd party transfer mode - after
  1281. the transfer on source host */
  1282. struct curl_slist *telnet_options; /* linked list of telnet options */
  1283. struct curl_slist *resolve; /* list of names to add/remove from
  1284. DNS cache */
  1285. curl_TimeCond timecondition; /* kind of time/date comparison */
  1286. time_t timevalue; /* what time to compare with */
  1287. Curl_HttpReq httpreq; /* what kind of HTTP request (if any) is this */
  1288. long httpversion; /* when non-zero, a specific HTTP version requested to
  1289. be used in the library's request(s) */
  1290. struct ssl_config_data ssl; /* user defined SSL stuff */
  1291. curl_proxytype proxytype; /* what kind of proxy that is in use */
  1292. long dns_cache_timeout; /* DNS cache timeout */
  1293. long buffer_size; /* size of receive buffer to use */
  1294. void *private_data; /* application-private data */
  1295. struct Curl_one_easy *one_easy; /* When adding an easy handle to a multi
  1296. handle, an internal 'Curl_one_easy'
  1297. struct is created and this is a pointer
  1298. to the particular struct associated with
  1299. this SessionHandle */
  1300. struct curl_slist *http200aliases; /* linked list of aliases for http200 */
  1301. long ipver; /* the CURL_IPRESOLVE_* defines in the public header file
  1302. 0 - whatever, 1 - v2, 2 - v6 */
  1303. curl_off_t max_filesize; /* Maximum file size to download */
  1304. curl_ftpfile ftp_filemethod; /* how to get to a file when FTP is used */
  1305. int ftp_create_missing_dirs; /* 1 - create directories that don't exist
  1306. 2 - the same but also allow MKD to fail once
  1307. */
  1308. curl_sshkeycallback ssh_keyfunc; /* key matching callback */
  1309. void *ssh_keyfunc_userp; /* custom pointer to callback */
  1310. /* Here follows boolean settings that define how to behave during
  1311. this session. They are STATIC, set by libcurl users or at least initially
  1312. and they don't change during operations. */
  1313. bool printhost; /* printing host name in debug info */
  1314. bool get_filetime; /* get the time and get of the remote file */
  1315. bool tunnel_thru_httpproxy; /* use CONNECT through a HTTP proxy */
  1316. bool prefer_ascii; /* ASCII rather than binary */
  1317. bool ftp_append; /* append, not overwrite, on upload */
  1318. bool ftp_list_only; /* switch FTP command for listing directories */
  1319. bool ftp_use_port; /* use the FTP PORT command */
  1320. bool hide_progress; /* don't use the progress meter */
  1321. bool http_fail_on_error; /* fail on HTTP error codes >= 300 */
  1322. bool http_follow_location; /* follow HTTP redirects */
  1323. bool http_transfer_encoding; /* request compressed HTTP transfer-encoding */
  1324. bool http_disable_hostname_check_before_authentication;
  1325. bool include_header; /* include received protocol headers in data output */
  1326. bool http_set_referer; /* is a custom referer used */
  1327. bool http_auto_referer; /* set "correct" referer when following location: */
  1328. bool opt_no_body; /* as set with CURLOPT_NO_BODY */
  1329. bool set_port; /* custom port number used */
  1330. bool upload; /* upload request */
  1331. enum CURL_NETRC_OPTION
  1332. use_netrc; /* defined in include/curl.h */
  1333. bool verbose; /* output verbosity */
  1334. bool krb; /* kerberos connection requested */
  1335. bool reuse_forbid; /* forbidden to be reused, close after use */
  1336. bool reuse_fresh; /* do not re-use an existing connection */
  1337. bool ftp_use_epsv; /* if EPSV is to be attempted or not */
  1338. bool ftp_use_eprt; /* if EPRT is to be attempted or not */
  1339. bool ftp_use_pret; /* if PRET is to be used before PASV or not */
  1340. curl_usessl use_ssl; /* if AUTH TLS is to be attempted etc, for FTP or
  1341. IMAP or POP3 or others! */
  1342. curl_ftpauth ftpsslauth; /* what AUTH XXX to be attempted */
  1343. curl_ftpccc ftp_ccc; /* FTP CCC options */
  1344. bool no_signal; /* do not use any signal/alarm handler */
  1345. bool global_dns_cache; /* subject for future removal */
  1346. bool tcp_nodelay; /* whether to enable TCP_NODELAY or not */
  1347. bool ignorecl; /* ignore content length */
  1348. bool ftp_skip_ip; /* skip the IP address the FTP server passes on to
  1349. us */
  1350. bool connect_only; /* make connection, let application use the socket */
  1351. bool ssl_enable_beast; /* especially allow this flaw for interoperability's
  1352. sake*/
  1353. long ssh_auth_types; /* allowed SSH auth types */
  1354. bool http_te_skip; /* pass the raw body data to the user, even when
  1355. transfer-encoded (chunked, compressed) */
  1356. bool http_ce_skip; /* pass the raw body data to the user, even when
  1357. content-encoded (chunked, compressed) */
  1358. long new_file_perms; /* Permissions to use when creating remote files */
  1359. long new_directory_perms; /* Permissions to use when creating remote dirs */
  1360. bool proxy_transfer_mode; /* set transfer mode (;type=<a|i>) when doing FTP
  1361. via an HTTP proxy */
  1362. char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */
  1363. unsigned int scope; /* address scope for IPv6 */
  1364. long allowed_protocols;
  1365. long redir_protocols;
  1366. #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
  1367. long socks5_gssapi_nec; /* flag to support nec socks5 server */
  1368. #endif
  1369. struct curl_slist *mail_rcpt; /* linked list of mail recipients */
  1370. /* Common RTSP header options */
  1371. Curl_RtspReq rtspreq; /* RTSP request type */
  1372. long rtspversion; /* like httpversion, for RTSP */
  1373. bool wildcardmatch; /* enable wildcard matching */
  1374. curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer
  1375. starts */
  1376. curl_chunk_end_callback chunk_end; /* called after part transferring
  1377. stopped */
  1378. curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds
  1379. to pattern (e.g. if WILDCARDMATCH is on) */
  1380. void *fnmatch_data;
  1381. long gssapi_delegation; /* GSSAPI credential delegation, see the
  1382. documentation of CURLOPT_GSSAPI_DELEGATION */
  1383. bool tcp_keepalive; /* use TCP keepalives */
  1384. long tcp_keepidle; /* seconds in idle before sending keepalive probe */
  1385. long tcp_keepintvl; /* seconds between TCP keepalive probes */
  1386. };
  1387. struct Names {
  1388. struct curl_hash *hostcache;
  1389. enum {
  1390. HCACHE_NONE, /* not pointing to anything */
  1391. HCACHE_PRIVATE, /* points to our own */
  1392. HCACHE_GLOBAL, /* points to the (shrug) global one */
  1393. HCACHE_MULTI, /* points to a shared one in the multi handle */
  1394. HCACHE_SHARED /* points to a shared one in a shared object */
  1395. } hostcachetype;
  1396. };
  1397. /*
  1398. * The 'connectdata' struct MUST have all the connection oriented stuff as we
  1399. * may have several simultaneous connections and connection structs in memory.
  1400. *
  1401. * The 'struct UserDefined' must only contain data that is set once to go for
  1402. * many (perhaps) independent connections. Values that are generated or
  1403. * calculated internally for the "session handle" must be defined within the
  1404. * 'struct UrlState' instead.
  1405. */
  1406. struct SessionHandle {
  1407. struct Names dns;
  1408. struct Curl_multi *multi; /* if non-NULL, points to the multi handle
  1409. struct to which this "belongs" */
  1410. struct Curl_one_easy *multi_pos; /* if non-NULL, points to its position
  1411. in multi controlling structure to assist
  1412. in removal. */
  1413. struct Curl_share *share; /* Share, handles global variable mutexing */
  1414. struct SingleRequest req; /* Request-specific data */
  1415. struct UserDefined set; /* values set by the libcurl user */
  1416. struct DynamicStatic change; /* possibly modified userdefined data */
  1417. struct CookieInfo *cookies; /* the cookies, read from files and servers.
  1418. NOTE that the 'cookie' field in the
  1419. UserDefined struct defines if the "engine"
  1420. is to be used or not. */
  1421. struct Progress progress; /* for all the progress meter data */
  1422. struct UrlState state; /* struct for fields used for state info and
  1423. other dynamic purposes */
  1424. struct WildcardData wildcard; /* wildcard download state info */
  1425. struct PureInfo info; /* stats, reports and info data */
  1426. #if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
  1427. iconv_t outbound_cd; /* for translating to the network encoding */
  1428. iconv_t inbound_cd; /* for translating from the network encoding */
  1429. iconv_t utf8_cd; /* for translating to UTF8 */
  1430. #endif /* CURL_DOES_CONVERSIONS && HAVE_ICONV */
  1431. unsigned int magic; /* set to a CURLEASY_MAGIC_NUMBER */
  1432. };
  1433. #define LIBCURL_NAME "libcurl"
  1434. #endif /* HEADER_CURL_URLDATA_H */