1
0

urldata.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. #ifndef __URLDATA_H
  2. #define __URLDATA_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2002, Daniel Stenberg, <[email protected]>, 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. * $Id$
  24. ***************************************************************************/
  25. /* This file is for lib internal stuff */
  26. #include "setup.h"
  27. #define PORT_FTP 21
  28. #define PORT_TELNET 23
  29. #define PORT_GOPHER 70
  30. #define PORT_HTTP 80
  31. #define PORT_HTTPS 443
  32. #define PORT_DICT 2628
  33. #define PORT_LDAP 389
  34. #define DICT_MATCH "/MATCH:"
  35. #define DICT_MATCH2 "/M:"
  36. #define DICT_MATCH3 "/FIND:"
  37. #define DICT_DEFINE "/DEFINE:"
  38. #define DICT_DEFINE2 "/D:"
  39. #define DICT_DEFINE3 "/LOOKUP:"
  40. #define CURL_DEFAULT_USER "anonymous"
  41. #define CURL_DEFAULT_PASSWORD "[email protected]"
  42. #include "cookie.h"
  43. #include "formdata.h"
  44. #ifdef USE_SSLEAY
  45. /* SSLeay stuff usually in /usr/local/ssl/include */
  46. #ifdef USE_OPENSSL
  47. #include "openssl/rsa.h"
  48. #include "openssl/crypto.h"
  49. #include "openssl/x509.h"
  50. #include "openssl/pem.h"
  51. #include "openssl/ssl.h"
  52. #include "openssl/err.h"
  53. #ifdef HAVE_OPENSSL_ENGINE_H
  54. #include <openssl/engine.h>
  55. #endif
  56. #else
  57. #include "rsa.h"
  58. #include "crypto.h"
  59. #include "x509.h"
  60. #include "pem.h"
  61. #include "ssl.h"
  62. #include "err.h"
  63. #endif
  64. #endif
  65. #ifdef HAVE_NETINET_IN_H
  66. #include <netinet/in.h>
  67. #endif
  68. #include "timeval.h"
  69. #include <curl/curl.h>
  70. #include "http_chunks.h" /* for the structs and enum stuff */
  71. #include "hostip.h"
  72. #include "hash.h"
  73. #ifdef HAVE_ZLIB_H
  74. #include <zlib.h> /* for content-encoding 08/28/02 jhrg */
  75. #endif
  76. /* Download buffer size, keep it fairly big for speed reasons */
  77. #define BUFSIZE CURL_MAX_WRITE_SIZE
  78. /* Initial size of the buffer to store headers in, it'll be enlarged in case
  79. of need. */
  80. #define HEADERSIZE 256
  81. /* Just a convenience macro to get the larger value out of two given */
  82. #ifndef MAX
  83. #define MAX(x,y) ((x)>(y)?(x):(y))
  84. #endif
  85. #ifdef KRB4
  86. /* Types needed for krb4-ftp connections */
  87. struct krb4buffer {
  88. void *data;
  89. size_t size;
  90. size_t index;
  91. int eof_flag;
  92. };
  93. enum protection_level {
  94. prot_clear,
  95. prot_safe,
  96. prot_confidential,
  97. prot_private
  98. };
  99. #endif
  100. #ifndef HAVE_OPENSSL_ENGINE_H
  101. typedef void ENGINE;
  102. #endif
  103. /* struct for data related to SSL and SSL connections */
  104. struct ssl_connect_data {
  105. bool use; /* use ssl encrypted communications TRUE/FALSE */
  106. #ifdef USE_SSLEAY
  107. /* these ones requires specific SSL-types */
  108. SSL_CTX* ctx;
  109. SSL* handle;
  110. X509* server_cert;
  111. #endif /* USE_SSLEAY */
  112. };
  113. /* information about one single SSL session */
  114. struct curl_ssl_session {
  115. char *name; /* host name for which this ID was used */
  116. void *sessionid; /* as returned from the SSL layer */
  117. long age; /* just a number, the higher the more recent */
  118. unsigned short remote_port; /* remote port to connect to */
  119. };
  120. struct ssl_config_data {
  121. long version; /* what version the client wants to use */
  122. long certverifyresult; /* result from the certificate verification */
  123. long verifypeer; /* set TRUE if this is desired */
  124. long verifyhost; /* 0: no verify
  125. 1: check that CN exists
  126. 2: CN must match hostname */
  127. char *CApath; /* DOES NOT WORK ON WINDOWS */
  128. char *CAfile; /* cerficate to verify peer against */
  129. char *random_file; /* path to file containing "random" data */
  130. char *egdsocket; /* path to file containing the EGD daemon socket */
  131. char *cipher_list; /* list of ciphers to use */
  132. long numsessions; /* SSL session id cache size */
  133. };
  134. /****************************************************************************
  135. * HTTP unique setup
  136. ***************************************************************************/
  137. struct HTTP {
  138. struct FormData *sendit;
  139. int postsize;
  140. char *postdata;
  141. const char *p_pragma; /* Pragma: string */
  142. const char *p_accept; /* Accept: string */
  143. long readbytecount;
  144. long writebytecount;
  145. /* For FORM posting */
  146. struct Form form;
  147. struct Curl_chunker chunk;
  148. struct back {
  149. curl_read_callback fread; /* backup storage for fread pointer */
  150. void *fread_in; /* backup storage for fread_in pointer */
  151. char *postdata;
  152. int postsize;
  153. } backup;
  154. enum {
  155. HTTPSEND_NADA, /* init */
  156. HTTPSEND_REQUEST, /* sending a request */
  157. HTTPSEND_BODY, /* sending body */
  158. HTTPSEND_LAST /* never use this */
  159. } sending;
  160. void *send_buffer; /* used if the request couldn't be sent in one chunk,
  161. points to an allocated send_buffer struct */
  162. };
  163. /****************************************************************************
  164. * FTP unique setup
  165. ***************************************************************************/
  166. struct FTP {
  167. long *bytecountp;
  168. char *user; /* user name string */
  169. char *passwd; /* password string */
  170. char *urlpath; /* the originally given path part of the URL */
  171. char *dir; /* decoded directory */
  172. char *file; /* decoded file */
  173. char *entrypath; /* the PWD reply when we logged on */
  174. char *cache; /* data cache between getresponse()-calls */
  175. size_t cache_size; /* size of cache in bytes */
  176. bool dont_check; /* Set to TRUE to prevent the final (post-transfer)
  177. file size and 226/250 status check. It should still
  178. read the line, just ignore the result. */
  179. bool no_transfer; /* nothing was transfered, (possibly because a resumed
  180. transfer already was complete) */
  181. long response_time; /* When no timeout is given, this is the amount of
  182. seconds we await for an FTP response. Initialized
  183. in Curl_ftp_connect() */
  184. };
  185. /****************************************************************************
  186. * FILE unique setup
  187. ***************************************************************************/
  188. struct FILE {
  189. int fd; /* open file descriptor to read from! */
  190. };
  191. /*
  192. * Boolean values that concerns this connection.
  193. */
  194. struct ConnectBits {
  195. bool close; /* if set, we close the connection after this request */
  196. bool reuse; /* if set, this is a re-used connection */
  197. bool chunk; /* if set, this is a chunked transfer-encoding */
  198. bool httpproxy; /* if set, this transfer is done through a http proxy */
  199. bool user_passwd; /* do we use user+password for this connection? */
  200. bool proxy_user_passwd; /* user+password for the proxy? */
  201. bool ipv6_ip; /* we communicate with a remove site specified with pure IPv6
  202. IP address */
  203. bool use_range;
  204. bool rangestringalloc; /* the range string is malloc()'ed */
  205. bool do_more; /* this is set TRUE if the ->curl_do_more() function is
  206. supposed to be called, after ->curl_do() */
  207. bool upload_chunky; /* set TRUE if we are doing chunked transfer-encoding
  208. on upload */
  209. bool getheader; /* TRUE if header parsing is wanted */
  210. bool forbidchunk; /* used only to explicitly forbid chunk-upload for
  211. specific upload buffers. See readmoredata() in
  212. http.c for details. */
  213. bool tcpconnect; /* the tcp stream (or simimlar) is connected, this
  214. is set the first time on the first connect function
  215. call */
  216. };
  217. /*
  218. * This struct is all the previously local variables from Curl_perform() moved
  219. * to struct to allow the function to return and get re-invoked better without
  220. * losing state.
  221. */
  222. struct Curl_transfer_keeper {
  223. int bytecount; /* total number of bytes read */
  224. int writebytecount; /* number of bytes written */
  225. long contentlength; /* size of incoming data */
  226. struct timeval start; /* transfer started at this time */
  227. struct timeval now; /* current time */
  228. bool header; /* incoming data has HTTP header */
  229. enum {
  230. HEADER_NORMAL, /* no bad header at all */
  231. HEADER_PARTHEADER, /* part of the chunk is a bad header, the rest is
  232. normal data */
  233. HEADER_ALLBAD /* all was believed to be header */
  234. } badheader; /* the header was deemed bad and will be
  235. written as body */
  236. int headerline; /* counts header lines to better track the
  237. first one */
  238. char *hbufp; /* points at *end* of header line */
  239. int hbuflen;
  240. char *str; /* within buf */
  241. char *str_start; /* within buf */
  242. char *end_ptr; /* within buf */
  243. char *p; /* within headerbuff */
  244. bool content_range; /* set TRUE if Content-Range: was found */
  245. int offset; /* possible resume offset read from the
  246. Content-Range: header */
  247. int httpcode; /* error code from the 'HTTP/1.? XXX' line */
  248. int httpversion; /* the HTTP version*10 */
  249. bool write_after_100_header; /* should we enable the write after
  250. we received a 100-continue/timeout
  251. or directly */
  252. int content_encoding; /* What content encoding. sec 3.5, RFC2616. */
  253. #define IDENTITY 0 /* No encoding */
  254. #define DEFLATE 1 /* zlib delfate [RFC 1950 & 1951] */
  255. #define GZIP 2 /* gzip algorithm [RFC 1952] */
  256. #define COMPRESS 3 /* Not handled, added for completeness */
  257. #ifdef HAVE_LIBZ
  258. bool zlib_init; /* True if zlib already initialized;
  259. undefined if Content-Encdoing header. */
  260. z_stream z; /* State structure for zlib. */
  261. #endif
  262. /* for the low speed checks: */
  263. time_t timeofdoc;
  264. long bodywrites;
  265. int writetype;
  266. char *buf;
  267. char *uploadbuf;
  268. int maxfd;
  269. /* pointers to the actual descriptors we check */
  270. fd_set *readfdp;
  271. fd_set *writefdp;
  272. /* the file descriptors to play with */
  273. fd_set readfd;
  274. fd_set writefd;
  275. fd_set rkeepfd;
  276. fd_set wkeepfd;
  277. int keepon;
  278. bool upload_done; /* set to TRUE when doing chunked transfer-encoding upload
  279. and we're uploading the last chunk */
  280. };
  281. /*
  282. * The connectdata struct contains all fields and variables that should be
  283. * unique for an entire connection.
  284. */
  285. struct connectdata {
  286. /**** Fields set when inited and not modified again */
  287. struct SessionHandle *data; /* link to the root CURL struct */
  288. int connectindex; /* what index in the connects index this particular
  289. struct has */
  290. long protocol; /* PROT_* flags concerning the protocol set */
  291. #define PROT_MISSING (1<<0)
  292. #define PROT_GOPHER (1<<1)
  293. #define PROT_HTTP (1<<2)
  294. #define PROT_HTTPS (1<<3)
  295. #define PROT_FTP (1<<4)
  296. #define PROT_TELNET (1<<5)
  297. #define PROT_DICT (1<<6)
  298. #define PROT_LDAP (1<<7)
  299. #define PROT_FILE (1<<8)
  300. #define PROT_FTPS (1<<9)
  301. #define PROT_SSL (1<<10) /* protocol requires SSL */
  302. /* the particular host we use, in two different ways */
  303. struct Curl_dns_entry *connect_addr;
  304. #ifdef ENABLE_IPV6
  305. struct addrinfo *serv_addr;
  306. #else
  307. struct sockaddr_in serv_addr;
  308. #endif
  309. char protostr[64]; /* store the protocol string in this buffer */
  310. char gname[513]; /* store the hostname in this buffer */
  311. char *name; /* host name pointer to fool around with */
  312. char *path; /* allocated buffer to store the URL's path part in */
  313. char *hostname; /* hostname to connect, as parsed from url */
  314. long port; /* which port to use locally */
  315. unsigned short remote_port; /* what remote port to connect to,
  316. not the proxy port! */
  317. char *ppath;
  318. long bytecount;
  319. long headerbytecount; /* only count received headers */
  320. char *range; /* range, if used. See README for detailed specification on
  321. this syntax. */
  322. ssize_t resume_from; /* continue [ftp] transfer from here */
  323. char *proxyhost; /* name of the http proxy host */
  324. struct timeval now; /* "current" time */
  325. struct timeval created; /* creation time */
  326. int firstsocket; /* the main socket to use */
  327. int secondarysocket; /* for i.e ftp transfers */
  328. long maxdownload; /* in bytes, the maximum amount of data to fetch, 0
  329. means unlimited */
  330. struct ssl_connect_data ssl; /* this is for ssl-stuff */
  331. struct ConnectBits bits; /* various state-flags for this connection */
  332. /* These two functions MUST be set by the curl_connect() function to be
  333. be protocol dependent */
  334. CURLcode (*curl_do)(struct connectdata *connect);
  335. CURLcode (*curl_done)(struct connectdata *connect);
  336. /* If the curl_do() function is better made in two halves, this
  337. * curl_do_more() function will be called afterwards, if set. For example
  338. * for doing the FTP stuff after the PASV/PORT command.
  339. */
  340. CURLcode (*curl_do_more)(struct connectdata *connect);
  341. /* This function *MAY* be set to a protocol-dependent function that is run
  342. * after the connect() and everything is done, as a step in the connection.
  343. */
  344. CURLcode (*curl_connect)(struct connectdata *connect);
  345. /* This function *MAY* be set to a protocol-dependent function that is run
  346. * by the curl_disconnect(), as a step in the disconnection.
  347. */
  348. CURLcode (*curl_disconnect)(struct connectdata *connect);
  349. /* This function *MAY* be set to a protocol-dependent function that is run
  350. * in the curl_close() function if protocol-specific cleanups are required.
  351. */
  352. CURLcode (*curl_close)(struct connectdata *connect);
  353. /**** curl_get() phase fields */
  354. /* READ stuff */
  355. int sockfd; /* socket to read from or -1 */
  356. int size; /* -1 if unknown at this point */
  357. long *bytecountp; /* return number of bytes read or NULL */
  358. /* WRITE stuff */
  359. int writesockfd; /* socket to write to, it may very well be
  360. the same we read from. -1 disables */
  361. long *writebytecountp; /* return number of bytes written or NULL */
  362. /** Dynamicly allocated strings, may need to be freed before this **/
  363. /** struct is killed. **/
  364. struct dynamically_allocated_data {
  365. char *proxyuserpwd; /* free later if not NULL! */
  366. char *uagent; /* free later if not NULL! */
  367. char *accept_encoding; /* free later if not NULL! 08/28/02 jhrg */
  368. char *userpwd; /* free later if not NULL! */
  369. char *rangeline; /* free later if not NULL! */
  370. char *ref; /* free later if not NULL! */
  371. char *cookie; /* free later if not NULL! */
  372. char *host; /* free later if not NULL */
  373. } allocptr;
  374. char *newurl; /* This can only be set if a Location: was in the
  375. document headers */
  376. #ifdef KRB4
  377. enum protection_level command_prot;
  378. enum protection_level data_prot;
  379. enum protection_level request_data_prot;
  380. size_t buffer_size;
  381. struct krb4buffer in_buffer, out_buffer;
  382. int sec_complete;
  383. void *app_data;
  384. struct Curl_sec_client_mech *mech;
  385. struct sockaddr_in local_addr;
  386. #endif
  387. /*************** Request - specific items ************/
  388. /* previously this was in the urldata struct */
  389. union {
  390. struct HTTP *http;
  391. struct HTTP *gopher; /* alias, just for the sake of being more readable */
  392. struct HTTP *https; /* alias, just for the sake of being more readable */
  393. struct FTP *ftp;
  394. struct FILE *file;
  395. void *telnet; /* private for telnet.c-eyes only */
  396. #if 0 /* no need for special ones for these: */
  397. struct LDAP *ldap;
  398. struct DICT *dict;
  399. #endif
  400. void *generic;
  401. } proto;
  402. /* This struct is inited when needed */
  403. struct Curl_transfer_keeper keep;
  404. /* 'upload_present' is used to keep a byte counter of how much data there is
  405. still left in the buffer, aimed for upload. */
  406. int upload_present;
  407. /* 'upload_fromhere' is used as a read-pointer when we uploaded parts of a
  408. buffer, so the next read should read from where this pointer points to,
  409. and the 'upload_present' contains the number of bytes available at this
  410. position */
  411. char *upload_fromhere;
  412. curl_read_callback fread; /* function that reads the input */
  413. void *fread_in; /* pointer to pass to the fread() above */
  414. };
  415. /* The end of connectdata. 08/27/02 jhrg */
  416. /*
  417. * Struct to keep statistical and informational data.
  418. */
  419. struct PureInfo {
  420. int httpcode;
  421. int httpversion;
  422. long filetime; /* If requested, this is might get set. Set to -1 if
  423. the time was unretrievable */
  424. long header_size; /* size of read header(s) in bytes */
  425. long request_size; /* the amount of bytes sent in the request(s) */
  426. char *contenttype; /* the content type of the object */
  427. };
  428. struct Progress {
  429. long lastshow; /* time() of the last displayed progress meter or NULL to
  430. force redraw at next call */
  431. double size_dl;
  432. double size_ul;
  433. double downloaded;
  434. double uploaded;
  435. double current_speed; /* uses the currently fastest transfer */
  436. bool callback; /* set when progress callback is used */
  437. int width; /* screen width at download start */
  438. int flags; /* see progress.h */
  439. double timespent;
  440. double dlspeed;
  441. double ulspeed;
  442. double t_nslookup;
  443. double t_connect;
  444. double t_pretransfer;
  445. double t_starttransfer;
  446. double t_redirect;
  447. struct timeval start;
  448. struct timeval t_startsingle;
  449. #define CURR_TIME (5+1) /* 6 entries for 5 seconds */
  450. double speeder[ CURR_TIME ];
  451. struct timeval speeder_time[ CURR_TIME ];
  452. int speeder_c;
  453. };
  454. typedef enum {
  455. HTTPREQ_NONE, /* first in list */
  456. HTTPREQ_GET,
  457. HTTPREQ_POST,
  458. HTTPREQ_POST_FORM, /* we make a difference internally */
  459. HTTPREQ_PUT,
  460. HTTPREQ_CUSTOM,
  461. HTTPREQ_LAST /* last in list */
  462. } Curl_HttpReq;
  463. /*
  464. * Values that are generated, temporary or calculated internally for a
  465. * "session handle" must be defined within the 'struct urlstate'. This struct
  466. * will be used within the SessionHandle struct. When the 'SessionHandle'
  467. * struct is cloned, this data MUST NOT be copied.
  468. *
  469. * Remember that any "state" information goes globally for the curl handle.
  470. * Session-data MUST be put in the connectdata struct and here. */
  471. #define MAX_CURL_USER_LENGTH 256
  472. #define MAX_CURL_PASSWORD_LENGTH 256
  473. struct UrlState {
  474. enum {
  475. Curl_if_none,
  476. Curl_if_easy,
  477. Curl_if_multi
  478. } used_interface;
  479. /* buffers to store authentication data in, as parsed from input options */
  480. char user[MAX_CURL_USER_LENGTH];
  481. char passwd[MAX_CURL_PASSWORD_LENGTH];
  482. char proxyuser[MAX_CURL_USER_LENGTH];
  483. char proxypasswd[MAX_CURL_PASSWORD_LENGTH];
  484. bool passwdgiven; /* set TRUE if an application-provided password has been
  485. set */
  486. struct timeval keeps_speed; /* for the progress meter really */
  487. /* 'connects' will be an allocated array with pointers. If the pointer is
  488. set, it holds an allocated connection. */
  489. struct connectdata **connects;
  490. long numconnects; /* size of the 'connects' array */
  491. char *headerbuff; /* allocated buffer to store headers in */
  492. int headersize; /* size of the allocation */
  493. char buffer[BUFSIZE+1]; /* download buffer */
  494. char uploadbuffer[BUFSIZE+1]; /* upload buffer */
  495. double current_speed; /* the ProgressShow() funcion sets this */
  496. bool this_is_a_follow; /* this is a followed Location: request */
  497. char *auth_host; /* if set, this should be the host name that we will
  498. sent authorization to, no else. Used to make Location:
  499. following not keep sending user+password... This is
  500. strdup() data.
  501. */
  502. struct curl_ssl_session *session; /* array of 'numsessions' size */
  503. long sessionage; /* number of the most recent session */
  504. char scratch[BUFSIZE*2]; /* huge buffer when doing upload CRLF replacing */
  505. bool errorbuf; /* Set to TRUE if the error buffer is already filled in.
  506. This must be set to FALSE every time _easy_perform() is
  507. called. */
  508. #ifdef HAVE_SIGNAL
  509. /* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */
  510. void (*prev_signal)(int sig);
  511. #endif
  512. bool allow_port; /* Is set.use_port allowed to take effect or not. This
  513. is always set TRUE when curl_easy_perform() is called. */
  514. };
  515. /*
  516. * This 'DynamicStatic' struct defines dynamic states that actually change
  517. * values in the 'UserDefined' area, which MUST be taken into consideration
  518. * if the UserDefined struct is cloned or similar. You can probably just
  519. * copy these, but each one indicate a special action on other data.
  520. */
  521. struct DynamicStatic {
  522. char *url; /* work URL, copied from UserDefined */
  523. bool url_alloc; /* URL string is malloc()'ed */
  524. char *proxy; /* work proxy, copied from UserDefined */
  525. bool proxy_alloc; /* http proxy string is malloc()'ed */
  526. char *referer; /* referer string */
  527. bool referer_alloc; /* referer sting is malloc()ed */
  528. struct curl_slist *cookielist; /* list of cookie files set by
  529. curl_easy_setopt(COOKIEFILE) calls */
  530. };
  531. /*
  532. * This 'UserDefined' struct must only contain data that is set once to go
  533. * for many (perhaps) independent connections. Values that are generated or
  534. * calculated internally for the "session handle" MUST be defined within the
  535. * 'struct urlstate' instead. The only exceptions MUST note the changes in
  536. * the 'DynamicStatic' struct.
  537. */
  538. struct UserDefined {
  539. FILE *err; /* the stderr user data goes here */
  540. void *debugdata; /* the data that will be passed to fdebug */
  541. char *errorbuffer; /* store failure messages in here */
  542. char *proxyuserpwd; /* Proxy <user:password>, if used */
  543. long proxyport; /* If non-zero, use this port number by default. If the
  544. proxy string features a ":[port]" that one will override
  545. this. */
  546. void *out; /* the fetched file goes here */
  547. void *in; /* the uploaded file is read from here */
  548. void *writeheader; /* write the header to this is non-NULL */
  549. char *set_url; /* what original URL to work on */
  550. char *set_proxy; /* proxy to use */
  551. long use_port; /* which port to use (when not using default) */
  552. char *userpwd; /* <user:password>, if used */
  553. char *set_range; /* range, if used. See README for detailed specification
  554. on this syntax. */
  555. long followlocation; /* as in HTTP Location: */
  556. long maxredirs; /* maximum no. of http(s) redirects to follow */
  557. char *set_referer; /* custom string */
  558. bool free_referer; /* set TRUE if 'referer' points to a string we
  559. allocated */
  560. char *useragent; /* User-Agent string */
  561. char *encoding; /* Accept-Encoding string */
  562. char *postfields; /* if POST, set the fields' values here */
  563. size_t postfieldsize; /* if POST, this might have a size to use instead of
  564. strlen(), and then the data *may* be binary (contain
  565. zero bytes) */
  566. char *ftpport; /* port to send with the FTP PORT command */
  567. char *device; /* network interface to use */
  568. curl_write_callback fwrite; /* function that stores the output */
  569. curl_write_callback fwrite_header; /* function that stores headers */
  570. curl_read_callback fread; /* function that reads the input */
  571. curl_progress_callback fprogress; /* function for progress information */
  572. curl_debug_callback fdebug; /* function that write informational data */
  573. void *progress_client; /* pointer to pass to the progress callback */
  574. curl_passwd_callback fpasswd; /* call for password */
  575. void *passwd_client; /* pass to the passwd callback */
  576. long timeout; /* in seconds, 0 means no timeout */
  577. long connecttimeout; /* in seconds, 0 means no timeout */
  578. long infilesize; /* size of file to upload, -1 means unknown */
  579. long low_speed_limit; /* bytes/second */
  580. long low_speed_time; /* number of seconds */
  581. int set_resume_from; /* continue [ftp] transfer from here */
  582. char *cookie; /* HTTP cookie string to send */
  583. struct curl_slist *headers; /* linked list of extra headers */
  584. struct HttpPost *httppost; /* linked list of POST data */
  585. char *cert; /* certificate */
  586. char *cert_type; /* format for certificate (default: PEM) */
  587. char *key; /* private key */
  588. char *key_type; /* format for private key (default: PEM) */
  589. char *key_passwd; /* plain text private key password */
  590. char *crypto_engine; /* name of the crypto engine to use */
  591. char *cookiejar; /* dump all cookies to this file */
  592. bool cookiesession; /* new cookie session? */
  593. bool crlf; /* convert crlf on ftp upload(?) */
  594. struct curl_slist *quote; /* after connection is established */
  595. struct curl_slist *postquote; /* after the transfer */
  596. struct curl_slist *prequote; /* before the transfer, after type (Wesley Laxton)*/
  597. struct curl_slist *telnet_options; /* linked list of telnet options */
  598. curl_TimeCond timecondition; /* kind of time/date comparison */
  599. time_t timevalue; /* what time to compare with */
  600. curl_closepolicy closepolicy; /* connection cache close concept */
  601. Curl_HttpReq httpreq; /* what kind of HTTP request (if any) is this */
  602. char *customrequest; /* HTTP/FTP request to use */
  603. long httpversion; /* when non-zero, a specific HTTP version requested to
  604. be used in the library's request(s) */
  605. char *auth_host; /* if set, this is the allocated string to the host name
  606. * to which to send the authorization data to, and no other
  607. * host (which location-following otherwise could lead to)
  608. */
  609. char *krb4_level; /* what security level */
  610. struct ssl_config_data ssl; /* user defined SSL stuff */
  611. curl_proxytype proxytype; /* what kind of proxy that is in use */
  612. int dns_cache_timeout; /* DNS cache timeout */
  613. long buffer_size; /* size of receive buffer to use */
  614. char *private; /* Private data */
  615. struct curl_slist *http200aliases; /* linked list of aliases for http200 */
  616. /* Here follows boolean settings that define how to behave during
  617. this session. They are STATIC, set by libcurl users or at least initially
  618. and they don't change during operations. */
  619. bool get_filetime;
  620. bool tunnel_thru_httpproxy;
  621. bool ftp_append;
  622. bool ftp_ascii;
  623. bool ftp_list_only;
  624. bool ftp_use_port;
  625. bool hide_progress;
  626. bool http_fail_on_error;
  627. bool http_follow_location;
  628. bool include_header;
  629. #define http_include_header include_header /* former name */
  630. bool http_set_referer;
  631. bool http_auto_referer; /* set "correct" referer when following location: */
  632. bool no_body;
  633. bool set_port;
  634. bool upload;
  635. enum CURL_NETRC_OPTION
  636. use_netrc; /* defined in include/curl.h */
  637. bool verbose;
  638. bool krb4; /* kerberos4 connection requested */
  639. bool reuse_forbid; /* forbidden to be reused, close after use */
  640. bool reuse_fresh; /* do not re-use an existing connection */
  641. bool expect100header; /* TRUE if we added Expect: 100-continue */
  642. bool ftp_use_epsv; /* if EPSV is to be attempted or not */
  643. bool no_signal; /* do not use any signal/alarm handler */
  644. bool global_dns_cache;
  645. };
  646. /*
  647. * In August 2001, this struct was redesigned and is since stricter than
  648. * before. The 'connectdata' struct MUST have all the connection oriented
  649. * stuff as we may now have several simultaneous connections and connection
  650. * structs in memory.
  651. *
  652. * From now on, the 'SessionHandle' must only contain data that is set once to
  653. * go for many (perhaps) independent connections. Values that are generated or
  654. * calculated internally for the "session handle" must be defined within the
  655. * 'struct urlstate' instead. */
  656. struct SessionHandle {
  657. curl_hash *hostcache;
  658. struct Curl_share *share; /* Share, handles global variable mutexing */
  659. struct UserDefined set; /* values set by the libcurl user */
  660. struct DynamicStatic change; /* possibly modified userdefined data */
  661. struct CookieInfo *cookies; /* the cookies, read from files and servers */
  662. struct Progress progress; /* for all the progress meter data */
  663. struct UrlState state; /* struct for fields used for state info and
  664. other dynamic purposes */
  665. struct PureInfo info; /* stats, reports and info data */
  666. #ifdef USE_SSLEAY
  667. ENGINE* engine;
  668. #endif /* USE_SSLEAY */
  669. };
  670. #define LIBCURL_NAME "libcurl"
  671. #endif