urldata.h 66 KB

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