urldata.h 65 KB

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