2
0

urldata.h 67 KB

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