urldata.h 65 KB

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