urldata.h
Go to the documentation of this file.
00001 #ifndef HEADER_CURL_URLDATA_H
00002 #define HEADER_CURL_URLDATA_H
00003 /***************************************************************************
00004  *                                  _   _ ____  _
00005  *  Project                     ___| | | |  _ \| |
00006  *                             / __| | | | |_) | |
00007  *                            | (__| |_| |  _ <| |___
00008  *                             \___|\___/|_| \_\_____|
00009  *
00010  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00011  *
00012  * This software is licensed as described in the file COPYING, which
00013  * you should have received as part of this distribution. The terms
00014  * are also available at https://curl.haxx.se/docs/copyright.html.
00015  *
00016  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00017  * copies of the Software, and permit persons to whom the Software is
00018  * furnished to do so, under the terms of the COPYING file.
00019  *
00020  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00021  * KIND, either express or implied.
00022  *
00023  ***************************************************************************/
00024 
00025 /* This file is for lib internal stuff */
00026 
00027 #include "curl_setup.h"
00028 
00029 #define PORT_FTP 21
00030 #define PORT_FTPS 990
00031 #define PORT_TELNET 23
00032 #define PORT_HTTP 80
00033 #define PORT_HTTPS 443
00034 #define PORT_DICT 2628
00035 #define PORT_LDAP 389
00036 #define PORT_LDAPS 636
00037 #define PORT_TFTP 69
00038 #define PORT_SSH 22
00039 #define PORT_IMAP 143
00040 #define PORT_IMAPS 993
00041 #define PORT_POP3 110
00042 #define PORT_POP3S 995
00043 #define PORT_SMB 445
00044 #define PORT_SMBS 445
00045 #define PORT_SMTP 25
00046 #define PORT_SMTPS 465 /* sometimes called SSMTP */
00047 #define PORT_RTSP 554
00048 #define PORT_RTMP 1935
00049 #define PORT_RTMPT PORT_HTTP
00050 #define PORT_RTMPS PORT_HTTPS
00051 #define PORT_GOPHER 70
00052 
00053 #define DICT_MATCH "/MATCH:"
00054 #define DICT_MATCH2 "/M:"
00055 #define DICT_MATCH3 "/FIND:"
00056 #define DICT_DEFINE "/DEFINE:"
00057 #define DICT_DEFINE2 "/D:"
00058 #define DICT_DEFINE3 "/LOOKUP:"
00059 
00060 #define CURL_DEFAULT_USER "anonymous"
00061 #define CURL_DEFAULT_PASSWORD "ftp@example.com"
00062 
00063 /* Convenience defines for checking protocols or their SSL based version. Each
00064    protocol handler should only ever have a single CURLPROTO_ in its protocol
00065    field. */
00066 #define PROTO_FAMILY_HTTP (CURLPROTO_HTTP|CURLPROTO_HTTPS)
00067 #define PROTO_FAMILY_FTP  (CURLPROTO_FTP|CURLPROTO_FTPS)
00068 #define PROTO_FAMILY_POP3 (CURLPROTO_POP3|CURLPROTO_POP3S)
00069 #define PROTO_FAMILY_SMB  (CURLPROTO_SMB|CURLPROTO_SMBS)
00070 #define PROTO_FAMILY_SMTP (CURLPROTO_SMTP|CURLPROTO_SMTPS)
00071 
00072 #define DEFAULT_CONNCACHE_SIZE 5
00073 
00074 /* length of longest IPv6 address string including the trailing null */
00075 #define MAX_IPADR_LEN sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")
00076 
00077 /* Default FTP/IMAP etc response timeout in milliseconds.
00078    Symbian OS panics when given a timeout much greater than 1/2 hour.
00079 */
00080 #define RESP_TIMEOUT (1800*1000)
00081 
00082 #include "cookie.h"
00083 #include "formdata.h"
00084 
00085 #ifdef USE_OPENSSL
00086 #include <openssl/ssl.h>
00087 #ifdef HAVE_OPENSSL_ENGINE_H
00088 #include <openssl/engine.h>
00089 #endif
00090 #endif /* USE_OPENSSL */
00091 
00092 #ifdef USE_GNUTLS
00093 #include <gnutls/gnutls.h>
00094 #endif
00095 
00096 #ifdef USE_MBEDTLS
00097 
00098 #include <mbedtls/ssl.h>
00099 #include <mbedtls/version.h>
00100 #include <mbedtls/entropy.h>
00101 #include <mbedtls/ctr_drbg.h>
00102 
00103 #elif defined USE_POLARSSL
00104 
00105 #include <polarssl/ssl.h>
00106 #include <polarssl/version.h>
00107 #if POLARSSL_VERSION_NUMBER<0x01010000
00108 #include <polarssl/havege.h>
00109 #else
00110 #include <polarssl/entropy.h>
00111 #include <polarssl/ctr_drbg.h>
00112 #endif /* POLARSSL_VERSION_NUMBER<0x01010000 */
00113 
00114 #endif /* USE_POLARSSL */
00115 
00116 #ifdef USE_CYASSL
00117 #undef OCSP_REQUEST  /* avoid cyassl/openssl/ssl.h clash with wincrypt.h */
00118 #undef OCSP_RESPONSE /* avoid cyassl/openssl/ssl.h clash with wincrypt.h */
00119 #include <cyassl/openssl/ssl.h>
00120 #endif
00121 
00122 #ifdef USE_NSS
00123 #include <nspr.h>
00124 #include <pk11pub.h>
00125 #endif
00126 
00127 #ifdef USE_GSKIT
00128 #include <gskssl.h>
00129 #endif
00130 
00131 #ifdef USE_AXTLS
00132 #include <axTLS/config.h>
00133 #include <axTLS/ssl.h>
00134 #undef malloc
00135 #undef calloc
00136 #undef realloc
00137 #endif /* USE_AXTLS */
00138 
00139 #ifdef USE_SCHANNEL
00140 #include "curl_sspi.h"
00141 #include <schnlsp.h>
00142 #include <schannel.h>
00143 #endif
00144 
00145 #ifdef USE_DARWINSSL
00146 #include <Security/Security.h>
00147 /* For some reason, when building for iOS, the omnibus header above does
00148  * not include SecureTransport.h as of iOS SDK 5.1. */
00149 #include <Security/SecureTransport.h>
00150 #endif
00151 
00152 #ifdef HAVE_NETINET_IN_H
00153 #include <netinet/in.h>
00154 #endif
00155 
00156 #include "timeval.h"
00157 
00158 #ifdef HAVE_ZLIB_H
00159 #include <zlib.h>               /* for content-encoding */
00160 #ifdef __SYMBIAN32__
00161 /* zlib pollutes the namespace with this definition */
00162 #undef WIN32
00163 #endif
00164 #endif
00165 
00166 #include <curl/curl.h>
00167 
00168 #include "http_chunks.h" /* for the structs and enum stuff */
00169 #include "hostip.h"
00170 #include "hash.h"
00171 #include "splay.h"
00172 
00173 #include "imap.h"
00174 #include "pop3.h"
00175 #include "smtp.h"
00176 #include "ftp.h"
00177 #include "file.h"
00178 #include "ssh.h"
00179 #include "http.h"
00180 #include "rtsp.h"
00181 #include "smb.h"
00182 #include "wildcard.h"
00183 #include "multihandle.h"
00184 
00185 #ifdef HAVE_GSSAPI
00186 # ifdef HAVE_GSSGNU
00187 #  include <gss.h>
00188 # elif defined HAVE_GSSMIT
00189 #  include <gssapi/gssapi.h>
00190 #  include <gssapi/gssapi_generic.h>
00191 # else
00192 #  include <gssapi.h>
00193 # endif
00194 #endif
00195 
00196 #ifdef HAVE_LIBSSH2_H
00197 #include <libssh2.h>
00198 #include <libssh2_sftp.h>
00199 #endif /* HAVE_LIBSSH2_H */
00200 
00201 /* Download buffer size, keep it fairly big for speed reasons */
00202 #undef BUFSIZE
00203 #define BUFSIZE CURL_MAX_WRITE_SIZE
00204 
00205 /* Initial size of the buffer to store headers in, it'll be enlarged in case
00206    of need. */
00207 #define HEADERSIZE 256
00208 
00209 #define CURLEASY_MAGIC_NUMBER 0xc0dedbadU
00210 #define GOOD_EASY_HANDLE(x) \
00211   ((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER))
00212 
00213 /* Some convenience macros to get the larger/smaller value out of two given.
00214    We prefix with CURL to prevent name collisions. */
00215 #define CURLMAX(x,y) ((x)>(y)?(x):(y))
00216 #define CURLMIN(x,y) ((x)<(y)?(x):(y))
00217 
00218 #ifdef HAVE_GSSAPI
00219 /* Types needed for krb5-ftp connections */
00220 struct krb5buffer {
00221   void *data;
00222   size_t size;
00223   size_t index;
00224   int eof_flag;
00225 };
00226 
00227 enum protection_level {
00228   PROT_NONE, /* first in list */
00229   PROT_CLEAR,
00230   PROT_SAFE,
00231   PROT_CONFIDENTIAL,
00232   PROT_PRIVATE,
00233   PROT_CMD,
00234   PROT_LAST /* last in list */
00235 };
00236 #endif
00237 
00238 #ifdef USE_SCHANNEL
00239 /* Structs to store Schannel handles */
00240 struct curl_schannel_cred {
00241   CredHandle cred_handle;
00242   TimeStamp time_stamp;
00243   int refcount;
00244 };
00245 
00246 struct curl_schannel_ctxt {
00247   CtxtHandle ctxt_handle;
00248   TimeStamp time_stamp;
00249 };
00250 #endif
00251 
00252 /* enum for the nonblocking SSL connection state machine */
00253 typedef enum {
00254   ssl_connect_1,
00255   ssl_connect_2,
00256   ssl_connect_2_reading,
00257   ssl_connect_2_writing,
00258   ssl_connect_3,
00259   ssl_connect_done
00260 } ssl_connect_state;
00261 
00262 typedef enum {
00263   ssl_connection_none,
00264   ssl_connection_negotiating,
00265   ssl_connection_complete
00266 } ssl_connection_state;
00267 
00268 /* struct for data related to each SSL connection */
00269 struct ssl_connect_data {
00270   /* Use ssl encrypted communications TRUE/FALSE, not necessarily using it atm
00271      but at least asked to or meaning to use it. See 'state' for the exact
00272      current state of the connection. */
00273   bool use;
00274   ssl_connection_state state;
00275   ssl_connect_state connecting_state;
00276 #if defined(USE_OPENSSL)
00277   /* these ones requires specific SSL-types */
00278   SSL_CTX* ctx;
00279   SSL*     handle;
00280   X509*    server_cert;
00281 #elif defined(USE_GNUTLS)
00282   gnutls_session_t session;
00283   gnutls_certificate_credentials_t cred;
00284 #ifdef USE_TLS_SRP
00285   gnutls_srp_client_credentials_t srp_client_cred;
00286 #endif
00287 #elif defined(USE_MBEDTLS)
00288   mbedtls_ctr_drbg_context ctr_drbg;
00289   mbedtls_entropy_context entropy;
00290   mbedtls_ssl_context ssl;
00291   int server_fd;
00292   mbedtls_x509_crt cacert;
00293   mbedtls_x509_crt clicert;
00294   mbedtls_x509_crl crl;
00295   mbedtls_pk_context pk;
00296   mbedtls_ssl_config config;
00297   const char *protocols[3];
00298 #elif defined(USE_POLARSSL)
00299   ctr_drbg_context ctr_drbg;
00300   entropy_context entropy;
00301   ssl_context ssl;
00302   int server_fd;
00303   x509_crt cacert;
00304   x509_crt clicert;
00305   x509_crl crl;
00306   rsa_context rsa;
00307 #elif defined(USE_CYASSL)
00308   SSL_CTX* ctx;
00309   SSL*     handle;
00310 #elif defined(USE_NSS)
00311   PRFileDesc *handle;
00312   char *client_nickname;
00313   struct Curl_easy *data;
00314   struct curl_llist *obj_list;
00315   PK11GenericObject *obj_clicert;
00316 #elif defined(USE_GSKIT)
00317   gsk_handle handle;
00318   int iocport;
00319   int localfd;
00320   int remotefd;
00321 #elif defined(USE_AXTLS)
00322   SSL_CTX* ssl_ctx;
00323   SSL*     ssl;
00324 #elif defined(USE_SCHANNEL)
00325   struct curl_schannel_cred *cred;
00326   struct curl_schannel_ctxt *ctxt;
00327   SecPkgContext_StreamSizes stream_sizes;
00328   size_t encdata_length, decdata_length;
00329   size_t encdata_offset, decdata_offset;
00330   unsigned char *encdata_buffer, *decdata_buffer;
00331   unsigned long req_flags, ret_flags;
00332   CURLcode recv_unrecoverable_err; /* schannel_recv had an unrecoverable err */
00333   bool recv_sspi_close_notify; /* true if connection closed by close_notify */
00334   bool recv_connection_closed; /* true if connection closed, regardless how */
00335   bool use_alpn; /* true if ALPN is used for this connection */
00336 #elif defined(USE_DARWINSSL)
00337   SSLContextRef ssl_ctx;
00338   curl_socket_t ssl_sockfd;
00339   bool ssl_direction; /* true if writing, false if reading */
00340   size_t ssl_write_buffered_length;
00341 #elif defined(USE_SSL)
00342 #error "SSL backend specific information missing from ssl_connect_data"
00343 #endif
00344 };
00345 
00346 struct ssl_primary_config {
00347   long version;          /* what version the client wants to use */
00348   bool verifypeer;       /* set TRUE if this is desired */
00349   bool verifyhost;       /* set TRUE if CN/SAN must match hostname */
00350   bool verifystatus;     /* set TRUE if certificate status must be checked */
00351   char *CApath;          /* certificate dir (doesn't work on windows) */
00352   char *CAfile;          /* certificate to verify peer against */
00353   char *clientcert;
00354   char *random_file;     /* path to file containing "random" data */
00355   char *egdsocket;       /* path to file containing the EGD daemon socket */
00356   char *cipher_list;     /* list of ciphers to use */
00357 };
00358 
00359 struct ssl_config_data {
00360   struct ssl_primary_config primary;
00361   bool enable_beast; /* especially allow this flaw for interoperability's
00362                         sake*/
00363   bool no_revoke;    /* disable SSL certificate revocation checks */
00364   long certverifyresult; /* result from the certificate verification */
00365   char *CRLfile;   /* CRL to check certificate revocation */
00366   char *issuercert;/* optional issuer certificate filename */
00367   curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
00368   void *fsslctxp;        /* parameter for call back */
00369   bool certinfo;         /* gather lots of certificate info */
00370   bool falsestart;
00371 
00372   char *cert; /* client certificate file name */
00373   char *cert_type; /* format for certificate (default: PEM)*/
00374   char *key; /* private key file name */
00375   char *key_type; /* format for private key (default: PEM) */
00376   char *key_passwd; /* plain text private key password */
00377 
00378 #ifdef USE_TLS_SRP
00379   char *username; /* TLS username (for, e.g., SRP) */
00380   char *password; /* TLS password (for, e.g., SRP) */
00381   enum CURL_TLSAUTH authtype; /* TLS authentication type (default SRP) */
00382 #endif
00383 };
00384 
00385 struct ssl_general_config {
00386   bool sessionid; /* cache session IDs or not */
00387   size_t max_ssl_sessions; /* SSL session id cache size */
00388 };
00389 
00390 /* information stored about one single SSL session */
00391 struct curl_ssl_session {
00392   char *name;       /* host name for which this ID was used */
00393   char *conn_to_host; /* host name for the connection (may be NULL) */
00394   const char *scheme; /* protocol scheme used */
00395   void *sessionid;  /* as returned from the SSL layer */
00396   size_t idsize;    /* if known, otherwise 0 */
00397   long age;         /* just a number, the higher the more recent */
00398   int remote_port;  /* remote port */
00399   int conn_to_port; /* remote port for the connection (may be -1) */
00400   struct ssl_primary_config ssl_config; /* setup for this session */
00401 };
00402 
00403 /* Struct used for Digest challenge-response authentication */
00404 struct digestdata {
00405 #if defined(USE_WINDOWS_SSPI)
00406   BYTE *input_token;
00407   size_t input_token_len;
00408 #else
00409   char *nonce;
00410   char *cnonce;
00411   char *realm;
00412   int algo;
00413   bool stale; /* set true for re-negotiation */
00414   char *opaque;
00415   char *qop;
00416   char *algorithm;
00417   int nc; /* nounce count */
00418 #endif
00419 };
00420 
00421 typedef enum {
00422   NTLMSTATE_NONE,
00423   NTLMSTATE_TYPE1,
00424   NTLMSTATE_TYPE2,
00425   NTLMSTATE_TYPE3,
00426   NTLMSTATE_LAST
00427 } curlntlm;
00428 
00429 #ifdef USE_WINDOWS_SSPI
00430 #include "curl_sspi.h"
00431 #endif
00432 
00433 #if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
00434 #include <iconv.h>
00435 #endif
00436 
00437 /* Struct used for GSSAPI (Kerberos V5) authentication */
00438 #if defined(USE_KERBEROS5)
00439 struct kerberos5data {
00440 #if defined(USE_WINDOWS_SSPI)
00441   CredHandle *credentials;
00442   CtxtHandle *context;
00443   TCHAR *spn;
00444   SEC_WINNT_AUTH_IDENTITY identity;
00445   SEC_WINNT_AUTH_IDENTITY *p_identity;
00446   size_t token_max;
00447   BYTE *output_token;
00448 #else
00449   gss_ctx_id_t context;
00450   gss_name_t spn;
00451 #endif
00452 };
00453 #endif
00454 
00455 /* Struct used for NTLM challenge-response authentication */
00456 #if defined(USE_NTLM)
00457 struct ntlmdata {
00458   curlntlm state;
00459 #ifdef USE_WINDOWS_SSPI
00460   CredHandle *credentials;
00461   CtxtHandle *context;
00462   SEC_WINNT_AUTH_IDENTITY identity;
00463   SEC_WINNT_AUTH_IDENTITY *p_identity;
00464   size_t token_max;
00465   BYTE *output_token;
00466   BYTE *input_token;
00467   size_t input_token_len;
00468 #else
00469   unsigned int flags;
00470   unsigned char nonce[8];
00471   void *target_info; /* TargetInfo received in the ntlm type-2 message */
00472   unsigned int target_info_len;
00473 #endif
00474 };
00475 #endif
00476 
00477 #ifdef USE_SPNEGO
00478 struct negotiatedata {
00479   /* When doing Negotiate (SPNEGO) auth, we first need to send a token
00480      and then validate the received one. */
00481   enum { GSS_AUTHNONE, GSS_AUTHRECV, GSS_AUTHSENT } state;
00482 #ifdef HAVE_GSSAPI
00483   OM_uint32 status;
00484   gss_ctx_id_t context;
00485   gss_name_t spn;
00486   gss_buffer_desc output_token;
00487 #else
00488 #ifdef USE_WINDOWS_SSPI
00489   DWORD status;
00490   CredHandle *credentials;
00491   CtxtHandle *context;
00492   SEC_WINNT_AUTH_IDENTITY identity;
00493   SEC_WINNT_AUTH_IDENTITY *p_identity;
00494   TCHAR *spn;
00495   size_t token_max;
00496   BYTE *output_token;
00497   size_t output_token_length;
00498 #endif
00499 #endif
00500 };
00501 #endif
00502 
00503 
00504 /*
00505  * Boolean values that concerns this connection.
00506  */
00507 struct ConnectBits {
00508   /* always modify bits.close with the connclose() and connkeep() macros! */
00509   bool close; /* if set, we close the connection after this request */
00510   bool reuse; /* if set, this is a re-used connection */
00511   bool conn_to_host; /* if set, this connection has a "connect to host"
00512                         that overrides the host in the URL */
00513   bool conn_to_port; /* if set, this connection has a "connect to port"
00514                         that overrides the port in the URL (remote port) */
00515   bool proxy; /* if set, this transfer is done through a proxy - any type */
00516   bool httpproxy;    /* if set, this transfer is done through a http proxy */
00517   bool socksproxy;   /* if set, this transfer is done through a socks proxy */
00518   bool user_passwd;    /* do we use user+password for this connection? */
00519   bool proxy_user_passwd; /* user+password for the proxy? */
00520   bool ipv6_ip; /* we communicate with a remote site specified with pure IPv6
00521                    IP address */
00522   bool ipv6;    /* we communicate with a site using an IPv6 address */
00523 
00524   bool do_more; /* this is set TRUE if the ->curl_do_more() function is
00525                    supposed to be called, after ->curl_do() */
00526   bool tcpconnect[2]; /* the TCP layer (or similar) is connected, this is set
00527                          the first time on the first connect function call */
00528   bool protoconnstart;/* the protocol layer has STARTED its operation after
00529                          the TCP layer connect */
00530 
00531   bool retry;         /* this connection is about to get closed and then
00532                          re-attempted at another connection. */
00533   bool tunnel_proxy;  /* if CONNECT is used to "tunnel" through the proxy.
00534                          This is implicit when SSL-protocols are used through
00535                          proxies, but can also be enabled explicitly by
00536                          apps */
00537   bool authneg;       /* TRUE when the auth phase has started, which means
00538                          that we are creating a request with an auth header,
00539                          but it is not the final request in the auth
00540                          negotiation. */
00541   bool rewindaftersend;/* TRUE when the sending couldn't be stopped even
00542                           though it will be discarded. When the whole send
00543                           operation is done, we must call the data rewind
00544                           callback. */
00545   bool ftp_use_epsv;  /* As set with CURLOPT_FTP_USE_EPSV, but if we find out
00546                          EPSV doesn't work we disable it for the forthcoming
00547                          requests */
00548 
00549   bool ftp_use_eprt;  /* As set with CURLOPT_FTP_USE_EPRT, but if we find out
00550                          EPRT doesn't work we disable it for the forthcoming
00551                          requests */
00552   bool ftp_use_data_ssl; /* Enabled SSL for the data connection */
00553   bool netrc;         /* name+password provided by netrc */
00554   bool userpwd_in_url; /* name+password found in url */
00555   bool stream_was_rewound; /* Indicates that the stream was rewound after a
00556                               request read past the end of its response byte
00557                               boundary */
00558   bool proxy_connect_closed; /* set true if a proxy disconnected the
00559                                 connection in a CONNECT request with auth, so
00560                                 that libcurl should reconnect and continue. */
00561   bool bound; /* set true if bind() has already been done on this socket/
00562                  connection */
00563   bool type_set;  /* type= was used in the URL */
00564   bool multiplex; /* connection is multiplexed */
00565 
00566   bool tcp_fastopen; /* use TCP Fast Open */
00567   bool tls_enable_npn;  /* TLS NPN extension? */
00568   bool tls_enable_alpn; /* TLS ALPN extension? */
00569   bool proxy_ssl_connected[2]; /* TRUE when SSL initialization for HTTPS proxy
00570                                   is complete */
00571   bool socksproxy_connecting; /* connecting through a socks proxy */
00572 };
00573 
00574 struct hostname {
00575   char *rawalloc; /* allocated "raw" version of the name */
00576   char *encalloc; /* allocated IDN-encoded version of the name */
00577   char *name;     /* name to use internally, might be encoded, might be raw */
00578   const char *dispname; /* name to display, as 'name' might be encoded */
00579 };
00580 
00581 /*
00582  * Flags on the keepon member of the Curl_transfer_keeper
00583  */
00584 
00585 #define KEEP_NONE  0
00586 #define KEEP_RECV  (1<<0)     /* there is or may be data to read */
00587 #define KEEP_SEND (1<<1)     /* there is or may be data to write */
00588 #define KEEP_RECV_HOLD (1<<2) /* when set, no reading should be done but there
00589                                  might still be data to read */
00590 #define KEEP_SEND_HOLD (1<<3) /* when set, no writing should be done but there
00591                                   might still be data to write */
00592 #define KEEP_RECV_PAUSE (1<<4) /* reading is paused */
00593 #define KEEP_SEND_PAUSE (1<<5) /* writing is paused */
00594 
00595 #define KEEP_RECVBITS (KEEP_RECV | KEEP_RECV_HOLD | KEEP_RECV_PAUSE)
00596 #define KEEP_SENDBITS (KEEP_SEND | KEEP_SEND_HOLD | KEEP_SEND_PAUSE)
00597 
00598 
00599 #ifdef HAVE_LIBZ
00600 typedef enum {
00601   ZLIB_UNINIT,          /* uninitialized */
00602   ZLIB_INIT,            /* initialized */
00603   ZLIB_GZIP_HEADER,     /* reading gzip header */
00604   ZLIB_GZIP_INFLATING,  /* inflating gzip stream */
00605   ZLIB_INIT_GZIP        /* initialized in transparent gzip mode */
00606 } zlibInitState;
00607 #endif
00608 
00609 #ifdef CURLRES_ASYNCH
00610 struct Curl_async {
00611   char *hostname;
00612   int port;
00613   struct Curl_dns_entry *dns;
00614   bool done;  /* set TRUE when the lookup is complete */
00615   int status; /* if done is TRUE, this is the status from the callback */
00616   void *os_specific;  /* 'struct thread_data' for Windows */
00617 };
00618 #endif
00619 
00620 #define FIRSTSOCKET     0
00621 #define SECONDARYSOCKET 1
00622 
00623 /* These function pointer types are here only to allow easier typecasting
00624    within the source when we need to cast between data pointers (such as NULL)
00625    and function pointers. */
00626 typedef CURLcode (*Curl_do_more_func)(struct connectdata *, int *);
00627 typedef CURLcode (*Curl_done_func)(struct connectdata *, CURLcode, bool);
00628 
00629 enum expect100 {
00630   EXP100_SEND_DATA,           /* enough waiting, just send the body now */
00631   EXP100_AWAITING_CONTINUE,   /* waiting for the 100 Continue header */
00632   EXP100_SENDING_REQUEST,     /* still sending the request but will wait for
00633                                  the 100 header once done with the request */
00634   EXP100_FAILED               /* used on 417 Expectation Failed */
00635 };
00636 
00637 enum upgrade101 {
00638   UPGR101_INIT,               /* default state */
00639   UPGR101_REQUESTED,          /* upgrade requested */
00640   UPGR101_RECEIVED,           /* response received */
00641   UPGR101_WORKING             /* talking upgraded protocol */
00642 };
00643 
00644 /*
00645  * Request specific data in the easy handle (Curl_easy).  Previously,
00646  * these members were on the connectdata struct but since a conn struct may
00647  * now be shared between different Curl_easys, we store connection-specific
00648  * data here. This struct only keeps stuff that's interesting for *this*
00649  * request, as it will be cleared between multiple ones
00650  */
00651 struct SingleRequest {
00652   curl_off_t size;        /* -1 if unknown at this point */
00653   curl_off_t *bytecountp; /* return number of bytes read or NULL */
00654 
00655   curl_off_t maxdownload; /* in bytes, the maximum amount of data to fetch,
00656                              -1 means unlimited */
00657   curl_off_t *writebytecountp; /* return number of bytes written or NULL */
00658 
00659   curl_off_t bytecount;         /* total number of bytes read */
00660   curl_off_t writebytecount;    /* number of bytes written */
00661 
00662   long headerbytecount;         /* only count received headers */
00663   long deductheadercount; /* this amount of bytes doesn't count when we check
00664                              if anything has been transferred at the end of a
00665                              connection. We use this counter to make only a
00666                              100 reply (without a following second response
00667                              code) result in a CURLE_GOT_NOTHING error code */
00668 
00669   struct timeval start;         /* transfer started at this time */
00670   struct timeval now;           /* current time */
00671   bool header;                  /* incoming data has HTTP header */
00672   enum {
00673     HEADER_NORMAL,              /* no bad header at all */
00674     HEADER_PARTHEADER,          /* part of the chunk is a bad header, the rest
00675                                    is normal data */
00676     HEADER_ALLBAD               /* all was believed to be header */
00677   } badheader;                  /* the header was deemed bad and will be
00678                                    written as body */
00679   int headerline;               /* counts header lines to better track the
00680                                    first one */
00681   char *hbufp;                  /* points at *end* of header line */
00682   size_t hbuflen;
00683   char *str;                    /* within buf */
00684   char *str_start;              /* within buf */
00685   char *end_ptr;                /* within buf */
00686   char *p;                      /* within headerbuff */
00687   bool content_range;           /* set TRUE if Content-Range: was found */
00688   curl_off_t offset;            /* possible resume offset read from the
00689                                    Content-Range: header */
00690   int httpcode;                 /* error code from the 'HTTP/1.? XXX' or
00691                                    'RTSP/1.? XXX' line */
00692   struct timeval start100;      /* time stamp to wait for the 100 code from */
00693   enum expect100 exp100;        /* expect 100 continue state */
00694   enum upgrade101 upgr101;      /* 101 upgrade state */
00695 
00696   int auto_decoding;            /* What content encoding. sec 3.5, RFC2616. */
00697 
00698 #define IDENTITY 0              /* No encoding */
00699 #define DEFLATE 1               /* zlib deflate [RFC 1950 & 1951] */
00700 #define GZIP 2                  /* gzip algorithm [RFC 1952] */
00701 
00702 #ifdef HAVE_LIBZ
00703   zlibInitState zlib_init;      /* possible zlib init state;
00704                                    undefined if Content-Encoding header. */
00705   z_stream z;                   /* State structure for zlib. */
00706 #endif
00707 
00708   time_t timeofdoc;
00709   long bodywrites;
00710 
00711   char *buf;
00712   char *uploadbuf;
00713   curl_socket_t maxfd;
00714 
00715   int keepon;
00716 
00717   bool upload_done; /* set to TRUE when doing chunked transfer-encoding upload
00718                        and we're uploading the last chunk */
00719 
00720   bool ignorebody;  /* we read a response-body but we ignore it! */
00721   bool ignorecl;    /* This HTTP response has no body so we ignore the Content-
00722                        Length: header */
00723 
00724   char *location;   /* This points to an allocated version of the Location:
00725                        header data */
00726   char *newurl;     /* Set to the new URL to use when a redirect or a retry is
00727                        wanted */
00728 
00729   /* 'upload_present' is used to keep a byte counter of how much data there is
00730      still left in the buffer, aimed for upload. */
00731   ssize_t upload_present;
00732 
00733    /* 'upload_fromhere' is used as a read-pointer when we uploaded parts of a
00734       buffer, so the next read should read from where this pointer points to,
00735       and the 'upload_present' contains the number of bytes available at this
00736       position */
00737   char *upload_fromhere;
00738 
00739   bool chunk; /* if set, this is a chunked transfer-encoding */
00740   bool upload_chunky; /* set TRUE if we are doing chunked transfer-encoding
00741                          on upload */
00742   bool getheader;     /* TRUE if header parsing is wanted */
00743 
00744   bool forbidchunk;   /* used only to explicitly forbid chunk-upload for
00745                          specific upload buffers. See readmoredata() in
00746                          http.c for details. */
00747 
00748   void *protop;       /* Allocated protocol-specific data. Each protocol
00749                          handler makes sure this points to data it needs. */
00750 };
00751 
00752 /*
00753  * Specific protocol handler.
00754  */
00755 
00756 struct Curl_handler {
00757   const char *scheme;        /* URL scheme name. */
00758 
00759   /* Complement to setup_connection_internals(). */
00760   CURLcode (*setup_connection)(struct connectdata *);
00761 
00762   /* These two functions MUST be set to be protocol dependent */
00763   CURLcode (*do_it)(struct connectdata *, bool *done);
00764   Curl_done_func done;
00765 
00766   /* If the curl_do() function is better made in two halves, this
00767    * curl_do_more() function will be called afterwards, if set. For example
00768    * for doing the FTP stuff after the PASV/PORT command.
00769    */
00770   Curl_do_more_func do_more;
00771 
00772   /* This function *MAY* be set to a protocol-dependent function that is run
00773    * after the connect() and everything is done, as a step in the connection.
00774    * The 'done' pointer points to a bool that should be set to TRUE if the
00775    * function completes before return. If it doesn't complete, the caller
00776    * should call the curl_connecting() function until it is.
00777    */
00778   CURLcode (*connect_it)(struct connectdata *, bool *done);
00779 
00780   /* See above. Currently only used for FTP. */
00781   CURLcode (*connecting)(struct connectdata *, bool *done);
00782   CURLcode (*doing)(struct connectdata *, bool *done);
00783 
00784   /* Called from the multi interface during the PROTOCONNECT phase, and it
00785      should then return a proper fd set */
00786   int (*proto_getsock)(struct connectdata *conn,
00787                        curl_socket_t *socks,
00788                        int numsocks);
00789 
00790   /* Called from the multi interface during the DOING phase, and it should
00791      then return a proper fd set */
00792   int (*doing_getsock)(struct connectdata *conn,
00793                        curl_socket_t *socks,
00794                        int numsocks);
00795 
00796   /* Called from the multi interface during the DO_MORE phase, and it should
00797      then return a proper fd set */
00798   int (*domore_getsock)(struct connectdata *conn,
00799                         curl_socket_t *socks,
00800                         int numsocks);
00801 
00802   /* Called from the multi interface during the DO_DONE, PERFORM and
00803      WAITPERFORM phases, and it should then return a proper fd set. Not setting
00804      this will make libcurl use the generic default one. */
00805   int (*perform_getsock)(const struct connectdata *conn,
00806                          curl_socket_t *socks,
00807                          int numsocks);
00808 
00809   /* This function *MAY* be set to a protocol-dependent function that is run
00810    * by the curl_disconnect(), as a step in the disconnection.  If the handler
00811    * is called because the connection has been considered dead, dead_connection
00812    * is set to TRUE.
00813    */
00814   CURLcode (*disconnect)(struct connectdata *, bool dead_connection);
00815 
00816   /* If used, this function gets called from transfer.c:readwrite_data() to
00817      allow the protocol to do extra reads/writes */
00818   CURLcode (*readwrite)(struct Curl_easy *data, struct connectdata *conn,
00819                         ssize_t *nread, bool *readmore);
00820 
00821   long defport;           /* Default port. */
00822   unsigned int protocol;  /* See CURLPROTO_* - this needs to be the single
00823                              specific protocol bit */
00824   unsigned int flags;     /* Extra particular characteristics, see PROTOPT_* */
00825 };
00826 
00827 #define PROTOPT_NONE 0             /* nothing extra */
00828 #define PROTOPT_SSL (1<<0)         /* uses SSL */
00829 #define PROTOPT_DUAL (1<<1)        /* this protocol uses two connections */
00830 #define PROTOPT_CLOSEACTION (1<<2) /* need action before socket close */
00831 /* some protocols will have to call the underlying functions without regard to
00832    what exact state the socket signals. IE even if the socket says "readable",
00833    the send function might need to be called while uploading, or vice versa.
00834 */
00835 #define PROTOPT_DIRLOCK (1<<3)
00836 #define PROTOPT_NONETWORK (1<<4)   /* protocol doesn't use the network! */
00837 #define PROTOPT_NEEDSPWD (1<<5)    /* needs a password, and if none is set it
00838                                       gets a default */
00839 #define PROTOPT_NOURLQUERY (1<<6)   /* protocol can't handle
00840                                         url query strings (?foo=bar) ! */
00841 #define PROTOPT_CREDSPERREQUEST (1<<7) /* requires login credentials per
00842                                           request instead of per connection */
00843 #define PROTOPT_ALPN_NPN (1<<8) /* set ALPN and/or NPN for this */
00844 #define PROTOPT_STREAM (1<<9) /* a protocol with individual logical streams */
00845 
00846 /* return the count of bytes sent, or -1 on error */
00847 typedef ssize_t (Curl_send)(struct connectdata *conn, /* connection data */
00848                             int sockindex,            /* socketindex */
00849                             const void *buf,          /* data to write */
00850                             size_t len,               /* max amount to write */
00851                             CURLcode *err);           /* error to return */
00852 
00853 /* return the count of bytes read, or -1 on error */
00854 typedef ssize_t (Curl_recv)(struct connectdata *conn, /* connection data */
00855                             int sockindex,            /* socketindex */
00856                             char *buf,                /* store data here */
00857                             size_t len,               /* max amount to read */
00858                             CURLcode *err);           /* error to return */
00859 
00860 #ifdef USE_RECV_BEFORE_SEND_WORKAROUND
00861 struct postponed_data {
00862   char *buffer;          /* Temporal store for received data during
00863                             sending, must be freed */
00864   size_t allocated_size; /* Size of temporal store */
00865   size_t recv_size;      /* Size of received data during sending */
00866   size_t recv_processed; /* Size of processed part of postponed data */
00867 #ifdef DEBUGBUILD
00868   curl_socket_t bindsock;/* Structure must be bound to specific socket,
00869                             used only for DEBUGASSERT */
00870 #endif /* DEBUGBUILD */
00871 };
00872 #endif /* USE_RECV_BEFORE_SEND_WORKAROUND */
00873 
00874 struct proxy_info {
00875   struct hostname host;
00876   long port;
00877   curl_proxytype proxytype; /* what kind of proxy that is in use */
00878   char *user;    /* proxy user name string, allocated */
00879   char *passwd;  /* proxy password string, allocated */
00880 };
00881 
00882 /*
00883  * The connectdata struct contains all fields and variables that should be
00884  * unique for an entire connection.
00885  */
00886 struct connectdata {
00887   /* 'data' is the CURRENT Curl_easy using this connection -- take great
00888      caution that this might very well vary between different times this
00889      connection is used! */
00890   struct Curl_easy *data;
00891 
00892   /* chunk is for HTTP chunked encoding, but is in the general connectdata
00893      struct only because we can do just about any protocol through a HTTP proxy
00894      and a HTTP proxy may in fact respond using chunked encoding */
00895   struct Curl_chunker chunk;
00896 
00897   curl_closesocket_callback fclosesocket; /* function closing the socket(s) */
00898   void *closesocket_client;
00899 
00900   bool inuse; /* This is a marker for the connection cache logic. If this is
00901                  TRUE this handle is being used by an easy handle and cannot
00902                  be used by any other easy handle without careful
00903                  consideration (== only for pipelining). */
00904 
00905   /**** Fields set when inited and not modified again */
00906   long connection_id; /* Contains a unique number to make it easier to
00907                          track the connections in the log output */
00908 
00909   /* 'dns_entry' is the particular host we use. This points to an entry in the
00910      DNS cache and it will not get pruned while locked. It gets unlocked in
00911      Curl_done(). This entry will be NULL if the connection is re-used as then
00912      there is no name resolve done. */
00913   struct Curl_dns_entry *dns_entry;
00914 
00915   /* 'ip_addr' is the particular IP we connected to. It points to a struct
00916      within the DNS cache, so this pointer is only valid as long as the DNS
00917      cache entry remains locked. It gets unlocked in Curl_done() */
00918   Curl_addrinfo *ip_addr;
00919   Curl_addrinfo *tempaddr[2]; /* for happy eyeballs */
00920 
00921   /* 'ip_addr_str' is the ip_addr data as a human readable string.
00922      It remains available as long as the connection does, which is longer than
00923      the ip_addr itself. */
00924   char ip_addr_str[MAX_IPADR_LEN];
00925 
00926   unsigned int scope_id;  /* Scope id for IPv6 */
00927 
00928   int socktype;  /* SOCK_STREAM or SOCK_DGRAM */
00929 
00930   struct hostname host;
00931   char *secondaryhostname; /* secondary socket host name (ftp) */
00932   struct hostname conn_to_host; /* the host to connect to. valid only if
00933                                    bits.conn_to_host is set */
00934   struct hostname proxy;
00935 
00936   struct proxy_info socks_proxy;
00937   struct proxy_info http_proxy;
00938 
00939   long port;       /* which port to use locally */
00940   int remote_port; /* the remote port, not the proxy port! */
00941   int conn_to_port; /* the remote port to connect to. valid only if
00942                        bits.conn_to_port is set */
00943   unsigned short secondary_port; /* secondary socket remote port to connect to
00944                                     (ftp) */
00945 
00946   /* 'primary_ip' and 'primary_port' get filled with peer's numerical
00947      ip address and port number whenever an outgoing connection is
00948      *attempted* from the primary socket to a remote address. When more
00949      than one address is tried for a connection these will hold data
00950      for the last attempt. When the connection is actually established
00951      these are updated with data which comes directly from the socket. */
00952 
00953   char primary_ip[MAX_IPADR_LEN];
00954   long primary_port;
00955 
00956   /* 'local_ip' and 'local_port' get filled with local's numerical
00957      ip address and port number whenever an outgoing connection is
00958      **established** from the primary socket to a remote address. */
00959 
00960   char local_ip[MAX_IPADR_LEN];
00961   long local_port;
00962 
00963   char *user;    /* user name string, allocated */
00964   char *passwd;  /* password string, allocated */
00965   char *options; /* options string, allocated */
00966 
00967   char *oauth_bearer; /* bearer token for OAuth 2.0, allocated */
00968 
00969   int httpversion;        /* the HTTP version*10 reported by the server */
00970   int rtspversion;        /* the RTSP version*10 reported by the server */
00971 
00972   struct timeval now;     /* "current" time */
00973   struct timeval created; /* creation time */
00974   curl_socket_t sock[2]; /* two sockets, the second is used for the data
00975                             transfer when doing FTP */
00976   curl_socket_t tempsock[2]; /* temporary sockets for happy eyeballs */
00977   bool sock_accepted[2]; /* TRUE if the socket on this index was created with
00978                             accept() */
00979   Curl_recv *recv[2];
00980   Curl_send *send[2];
00981 
00982 #ifdef USE_RECV_BEFORE_SEND_WORKAROUND
00983   struct postponed_data postponed[2]; /* two buffers for two sockets */
00984 #endif /* USE_RECV_BEFORE_SEND_WORKAROUND */
00985   struct ssl_connect_data ssl[2]; /* this is for ssl-stuff */
00986   struct ssl_connect_data proxy_ssl[2]; /* this is for proxy ssl-stuff */
00987   struct ssl_primary_config ssl_config;
00988   struct ssl_primary_config proxy_ssl_config;
00989   bool tls_upgraded;
00990 
00991   struct ConnectBits bits;    /* various state-flags for this connection */
00992 
00993  /* connecttime: when connect() is called on the current IP address. Used to
00994     be able to track when to move on to try next IP - but only when the multi
00995     interface is used. */
00996   struct timeval connecttime;
00997   /* The two fields below get set in Curl_connecthost */
00998   int num_addr; /* number of addresses to try to connect to */
00999   time_t timeoutms_per_addr; /* how long time in milliseconds to spend on
01000                                 trying to connect to each IP address */
01001 
01002   const struct Curl_handler *handler; /* Connection's protocol handler */
01003   const struct Curl_handler *given;   /* The protocol first given */
01004 
01005   long ip_version; /* copied from the Curl_easy at creation time */
01006 
01007   /**** curl_get() phase fields */
01008 
01009   curl_socket_t sockfd;   /* socket to read from or CURL_SOCKET_BAD */
01010   curl_socket_t writesockfd; /* socket to write to, it may very
01011                                 well be the same we read from.
01012                                 CURL_SOCKET_BAD disables */
01013 
01016   struct dynamically_allocated_data {
01017     char *proxyuserpwd;
01018     char *uagent;
01019     char *accept_encoding;
01020     char *userpwd;
01021     char *rangeline;
01022     char *ref;
01023     char *host;
01024     char *cookiehost;
01025     char *rtsp_transport;
01026     char *te; /* TE: request header */
01027   } allocptr;
01028 
01029 #ifdef HAVE_GSSAPI
01030   int sec_complete; /* if Kerberos is enabled for this connection */
01031   enum protection_level command_prot;
01032   enum protection_level data_prot;
01033   enum protection_level request_data_prot;
01034   size_t buffer_size;
01035   struct krb5buffer in_buffer;
01036   void *app_data;
01037   const struct Curl_sec_client_mech *mech;
01038   struct sockaddr_in local_addr;
01039 #endif
01040 
01041 #if defined(USE_KERBEROS5)    /* Consider moving some of the above GSS-API */
01042   struct kerberos5data krb5;  /* variables into the structure definition, */
01043 #endif                        /* however, some of them are ftp specific. */
01044 
01045   /* the two following *_inuse fields are only flags, not counters in any way.
01046      If TRUE it means the channel is in use, and if FALSE it means the channel
01047      is up for grabs by one. */
01048 
01049   bool readchannel_inuse;  /* whether the read channel is in use by an easy
01050                               handle */
01051   bool writechannel_inuse; /* whether the write channel is in use by an easy
01052                               handle */
01053   struct curl_llist *send_pipe; /* List of handles waiting to
01054                                    send on this pipeline */
01055   struct curl_llist *recv_pipe; /* List of handles waiting to read
01056                                    their responses on this pipeline */
01057   char *master_buffer; /* The master buffer allocated on-demand;
01058                           used for pipelining. */
01059   size_t read_pos; /* Current read position in the master buffer */
01060   size_t buf_len; /* Length of the buffer?? */
01061 
01062 
01063   curl_seek_callback seek_func; /* function that seeks the input */
01064   void *seek_client;            /* pointer to pass to the seek() above */
01065 
01066   /*************** Request - specific items ************/
01067 
01068 #if defined(USE_NTLM)
01069   struct ntlmdata ntlm;     /* NTLM differs from other authentication schemes
01070                                because it authenticates connections, not
01071                                single requests! */
01072   struct ntlmdata proxyntlm; /* NTLM data for proxy */
01073 
01074 #if defined(NTLM_WB_ENABLED)
01075   /* used for communication with Samba's winbind daemon helper ntlm_auth */
01076   curl_socket_t ntlm_auth_hlpr_socket;
01077   pid_t ntlm_auth_hlpr_pid;
01078   char *challenge_header;
01079   char *response_header;
01080 #endif
01081 #endif
01082 
01083   char syserr_buf [256]; /* buffer for Curl_strerror() */
01084 
01085 #ifdef CURLRES_ASYNCH
01086   /* data used for the asynch name resolve callback */
01087   struct Curl_async async;
01088 #endif
01089 
01090   /* These three are used for chunked-encoding trailer support */
01091   char *trailer; /* allocated buffer to store trailer in */
01092   int trlMax;    /* allocated buffer size */
01093   int trlPos;    /* index of where to store data */
01094 
01095   union {
01096     struct ftp_conn ftpc;
01097     struct http_conn httpc;
01098     struct ssh_conn sshc;
01099     struct tftp_state_data *tftpc;
01100     struct imap_conn imapc;
01101     struct pop3_conn pop3c;
01102     struct smtp_conn smtpc;
01103     struct rtsp_conn rtspc;
01104     struct smb_conn smbc;
01105     void *generic; /* RTMP and LDAP use this */
01106   } proto;
01107 
01108   int cselect_bits; /* bitmask of socket events */
01109   int waitfor;      /* current READ/WRITE bits to wait for */
01110 
01111 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
01112   int socks5_gssapi_enctype;
01113 #endif
01114 
01115   /* When this connection is created, store the conditions for the local end
01116      bind. This is stored before the actual bind and before any connection is
01117      made and will serve the purpose of being used for comparison reasons so
01118      that subsequent bound-requested connections aren't accidentally re-using
01119      wrong connections. */
01120   char *localdev;
01121   unsigned short localport;
01122   int localportrange;
01123 
01124   /* tunnel as in tunnel through a HTTP proxy with CONNECT */
01125   enum {
01126     TUNNEL_INIT,    /* init/default/no tunnel state */
01127     TUNNEL_CONNECT, /* CONNECT has been sent off */
01128     TUNNEL_COMPLETE /* CONNECT response received completely */
01129   } tunnel_state[2]; /* two separate ones to allow FTP */
01130   struct connectbundle *bundle; /* The bundle we are member of */
01131 
01132   int negnpn; /* APLN or NPN TLS negotiated protocol, CURL_HTTP_VERSION* */
01133 
01134 #ifdef USE_UNIX_SOCKETS
01135   char *unix_domain_socket;
01136 #endif
01137 };
01138 
01139 /* The end of connectdata. */
01140 
01141 /*
01142  * Struct to keep statistical and informational data.
01143  * All variables in this struct must be initialized/reset in Curl_initinfo().
01144  */
01145 struct PureInfo {
01146   int httpcode;  /* Recent HTTP, FTP, RTSP or SMTP response code */
01147   int httpproxycode; /* response code from proxy when received separate */
01148   int httpversion; /* the http version number X.Y = X*10+Y */
01149   long filetime; /* If requested, this is might get set. Set to -1 if the time
01150                     was unretrievable. We cannot have this of type time_t,
01151                     since time_t is unsigned on several platforms such as
01152                     OpenVMS. */
01153   bool timecond;  /* set to TRUE if the time condition didn't match, which
01154                      thus made the document NOT get fetched */
01155   long header_size;  /* size of read header(s) in bytes */
01156   long request_size; /* the amount of bytes sent in the request(s) */
01157   unsigned long proxyauthavail; /* what proxy auth types were announced */
01158   unsigned long httpauthavail;  /* what host auth types were announced */
01159   long numconnects; /* how many new connection did libcurl created */
01160   char *contenttype; /* the content type of the object */
01161   char *wouldredirect; /* URL this would've been redirected to if asked to */
01162 
01163   /* PureInfo members 'conn_primary_ip', 'conn_primary_port', 'conn_local_ip'
01164      and, 'conn_local_port' are copied over from the connectdata struct in
01165      order to allow curl_easy_getinfo() to return this information even when
01166      the session handle is no longer associated with a connection, and also
01167      allow curl_easy_reset() to clear this information from the session handle
01168      without disturbing information which is still alive, and that might be
01169      reused, in the connection cache. */
01170 
01171   char conn_primary_ip[MAX_IPADR_LEN];
01172   long conn_primary_port;
01173 
01174   char conn_local_ip[MAX_IPADR_LEN];
01175   long conn_local_port;
01176 
01177   const char *conn_scheme;
01178   unsigned int conn_protocol;
01179 
01180   struct curl_certinfo certs; /* info about the certs, only populated in
01181                                  OpenSSL builds. Asked for with
01182                                  CURLOPT_CERTINFO / CURLINFO_CERTINFO */
01183 };
01184 
01185 
01186 struct Progress {
01187   time_t lastshow; /* time() of the last displayed progress meter or NULL to
01188                       force redraw at next call */
01189   curl_off_t size_dl; /* total expected size */
01190   curl_off_t size_ul; /* total expected size */
01191   curl_off_t downloaded; /* transferred so far */
01192   curl_off_t uploaded; /* transferred so far */
01193 
01194   curl_off_t current_speed; /* uses the currently fastest transfer */
01195 
01196   bool callback;  /* set when progress callback is used */
01197   int width; /* screen width at download start */
01198   int flags; /* see progress.h */
01199 
01200   double timespent;
01201 
01202   curl_off_t dlspeed;
01203   curl_off_t ulspeed;
01204 
01205   double t_nslookup;
01206   double t_connect;
01207   double t_appconnect;
01208   double t_pretransfer;
01209   double t_starttransfer;
01210   double t_redirect;
01211 
01212   struct timeval start;
01213   struct timeval t_startsingle;
01214   struct timeval t_startop;
01215   struct timeval t_acceptdata;
01216 
01217   /* upload speed limit */
01218   struct timeval ul_limit_start;
01219   curl_off_t ul_limit_size;
01220   /* download speed limit */
01221   struct timeval dl_limit_start;
01222   curl_off_t dl_limit_size;
01223 
01224 #define CURR_TIME (5+1) /* 6 entries for 5 seconds */
01225 
01226   curl_off_t speeder[ CURR_TIME ];
01227   struct timeval speeder_time[ CURR_TIME ];
01228   int speeder_c;
01229 };
01230 
01231 typedef enum {
01232   HTTPREQ_NONE, /* first in list */
01233   HTTPREQ_GET,
01234   HTTPREQ_POST,
01235   HTTPREQ_POST_FORM, /* we make a difference internally */
01236   HTTPREQ_PUT,
01237   HTTPREQ_HEAD,
01238   HTTPREQ_CUSTOM,
01239   HTTPREQ_LAST /* last in list */
01240 } Curl_HttpReq;
01241 
01242 typedef enum {
01243     RTSPREQ_NONE, /* first in list */
01244     RTSPREQ_OPTIONS,
01245     RTSPREQ_DESCRIBE,
01246     RTSPREQ_ANNOUNCE,
01247     RTSPREQ_SETUP,
01248     RTSPREQ_PLAY,
01249     RTSPREQ_PAUSE,
01250     RTSPREQ_TEARDOWN,
01251     RTSPREQ_GET_PARAMETER,
01252     RTSPREQ_SET_PARAMETER,
01253     RTSPREQ_RECORD,
01254     RTSPREQ_RECEIVE,
01255     RTSPREQ_LAST /* last in list */
01256 } Curl_RtspReq;
01257 
01258 /*
01259  * Values that are generated, temporary or calculated internally for a
01260  * "session handle" must be defined within the 'struct UrlState'.  This struct
01261  * will be used within the Curl_easy struct. When the 'Curl_easy'
01262  * struct is cloned, this data MUST NOT be copied.
01263  *
01264  * Remember that any "state" information goes globally for the curl handle.
01265  * Session-data MUST be put in the connectdata struct and here.  */
01266 #define MAX_CURL_USER_LENGTH 256
01267 #define MAX_CURL_PASSWORD_LENGTH 256
01268 
01269 struct auth {
01270   unsigned long want;  /* Bitmask set to the authentication methods wanted by
01271                           app (with CURLOPT_HTTPAUTH or CURLOPT_PROXYAUTH). */
01272   unsigned long picked;
01273   unsigned long avail; /* Bitmask for what the server reports to support for
01274                           this resource */
01275   bool done;  /* TRUE when the auth phase is done and ready to do the *actual*
01276                  request */
01277   bool multi; /* TRUE if this is not yet authenticated but within the auth
01278                  multipass negotiation */
01279   bool iestyle; /* TRUE if digest should be done IE-style or FALSE if it should
01280                    be RFC compliant */
01281 };
01282 
01283 struct Curl_http2_dep {
01284   struct Curl_http2_dep *next;
01285   struct Curl_easy *data;
01286 };
01287 
01288 struct UrlState {
01289 
01290   /* Points to the connection cache */
01291   struct conncache *conn_cache;
01292 
01293   /* when curl_easy_perform() is called, the multi handle is "owned" by
01294      the easy handle so curl_easy_cleanup() on such an easy handle will
01295      also close the multi handle! */
01296   bool multi_owned_by_easy;
01297 
01298   /* buffers to store authentication data in, as parsed from input options */
01299   struct timeval keeps_speed; /* for the progress meter really */
01300 
01301   struct connectdata *lastconnect; /* The last connection, NULL if undefined */
01302 
01303   char *headerbuff; /* allocated buffer to store headers in */
01304   size_t headersize;   /* size of the allocation */
01305 
01306   char buffer[BUFSIZE+1]; /* download buffer */
01307   char uploadbuffer[BUFSIZE+1]; /* upload buffer */
01308   curl_off_t current_speed;  /* the ProgressShow() funcion sets this,
01309                                 bytes / second */
01310   bool this_is_a_follow; /* this is a followed Location: request */
01311 
01312   char *first_host; /* host name of the first (not followed) request.
01313                        if set, this should be the host name that we will
01314                        sent authorization to, no else. Used to make Location:
01315                        following not keep sending user+password... This is
01316                        strdup() data.
01317                     */
01318   int first_remote_port; /* remote port of the first (not followed) request */
01319   struct curl_ssl_session *session; /* array of 'max_ssl_sessions' size */
01320   long sessionage;                  /* number of the most recent session */
01321   char *tempwrite;      /* allocated buffer to keep data in when a write
01322                            callback returns to make the connection paused */
01323   size_t tempwritesize; /* size of the 'tempwrite' allocated buffer */
01324   int tempwritetype;    /* type of the 'tempwrite' buffer as a bitmask that is
01325                            used with Curl_client_write() */
01326   char *scratch; /* huge buffer[BUFSIZE*2] when doing upload CRLF replacing */
01327   bool errorbuf; /* Set to TRUE if the error buffer is already filled in.
01328                     This must be set to FALSE every time _easy_perform() is
01329                     called. */
01330   int os_errno;  /* filled in with errno whenever an error occurs */
01331 #ifdef HAVE_SIGNAL
01332   /* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */
01333   void (*prev_signal)(int sig);
01334 #endif
01335   bool allow_port; /* Is set.use_port allowed to take effect or not. This
01336                       is always set TRUE when curl_easy_perform() is called. */
01337   struct digestdata digest;      /* state data for host Digest auth */
01338   struct digestdata proxydigest; /* state data for proxy Digest auth */
01339 
01340 #ifdef USE_SPNEGO
01341   struct negotiatedata negotiate; /* state data for host Negotiate auth */
01342   struct negotiatedata proxyneg; /* state data for proxy Negotiate auth */
01343 #endif
01344 
01345   struct auth authhost;  /* auth details for host */
01346   struct auth authproxy; /* auth details for proxy */
01347 
01348   bool authproblem; /* TRUE if there's some problem authenticating */
01349 
01350   void *resolver; /* resolver state, if it is used in the URL state -
01351                      ares_channel f.e. */
01352 
01353 #if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H)
01354   ENGINE *engine;
01355 #endif /* USE_OPENSSL */
01356   struct timeval expiretime; /* set this with Curl_expire() only */
01357   struct Curl_tree timenode; /* for the splay stuff */
01358   struct curl_llist *timeoutlist; /* list of pending timeouts */
01359 
01360   /* a place to store the most recently set FTP entrypath */
01361   char *most_recent_ftp_entrypath;
01362 
01363   /* set after initial USER failure, to prevent an authentication loop */
01364   bool ftp_trying_alternative;
01365 
01366   int httpversion;       /* the lowest HTTP version*10 reported by any server
01367                             involved in this request */
01368   bool expect100header;  /* TRUE if we added Expect: 100-continue */
01369 
01370   bool pipe_broke; /* TRUE if the connection we were pipelined on broke
01371                       and we need to restart from the beginning */
01372 
01373 #if !defined(WIN32) && !defined(MSDOS) && !defined(__EMX__) && \
01374     !defined(__SYMBIAN32__)
01375 /* do FTP line-end conversions on most platforms */
01376 #define CURL_DO_LINEEND_CONV
01377   /* for FTP downloads: track CRLF sequences that span blocks */
01378   bool prev_block_had_trailing_cr;
01379   /* for FTP downloads: how many CRLFs did we converted to LFs? */
01380   curl_off_t crlf_conversions;
01381 #endif
01382   char *pathbuffer;/* allocated buffer to store the URL's path part in */
01383   char *path;      /* path to use, points to somewhere within the pathbuffer
01384                       area */
01385   bool slash_removed; /* set TRUE if the 'path' points to a path where the
01386                          initial URL slash separator has been taken off */
01387   bool use_range;
01388   bool rangestringalloc; /* the range string is malloc()'ed */
01389 
01390   char *range; /* range, if used. See README for detailed specification on
01391                   this syntax. */
01392   curl_off_t resume_from; /* continue [ftp] transfer from here */
01393 
01394   /* This RTSP state information survives requests and connections */
01395   long rtsp_next_client_CSeq; /* the session's next client CSeq */
01396   long rtsp_next_server_CSeq; /* the session's next server CSeq */
01397   long rtsp_CSeq_recv; /* most recent CSeq received */
01398 
01399   curl_off_t infilesize; /* size of file to upload, -1 means unknown.
01400                             Copied from set.filesize at start of operation */
01401 
01402   size_t drain; /* Increased when this stream has data to read, even if its
01403                    socket is not necessarily is readable. Decreased when
01404                    checked. */
01405   bool done; /* set to FALSE when Curl_init_do() is called and set to TRUE
01406                 when multi_done() is called, to prevent multi_done() to get
01407                 invoked twice when the multi interface is used. */
01408 
01409   curl_read_callback fread_func; /* read callback/function */
01410   void *in;                      /* CURLOPT_READDATA */
01411 
01412   struct Curl_easy *stream_depends_on;
01413   bool stream_depends_e; /* set or don't set the Exclusive bit */
01414   int stream_weight;
01415 };
01416 
01417 
01418 /*
01419  * This 'DynamicStatic' struct defines dynamic states that actually change
01420  * values in the 'UserDefined' area, which MUST be taken into consideration
01421  * if the UserDefined struct is cloned or similar. You can probably just
01422  * copy these, but each one indicate a special action on other data.
01423  */
01424 
01425 struct DynamicStatic {
01426   char *url;        /* work URL, copied from UserDefined */
01427   bool url_alloc;   /* URL string is malloc()'ed */
01428   char *referer;    /* referer string */
01429   bool referer_alloc; /* referer sting is malloc()ed */
01430   struct curl_slist *cookielist; /* list of cookie files set by
01431                                     curl_easy_setopt(COOKIEFILE) calls */
01432   struct curl_slist *resolve; /* set to point to the set.resolve list when
01433                                  this should be dealt with in pretransfer */
01434 };
01435 
01436 /*
01437  * This 'UserDefined' struct must only contain data that is set once to go
01438  * for many (perhaps) independent connections. Values that are generated or
01439  * calculated internally for the "session handle" MUST be defined within the
01440  * 'struct UrlState' instead. The only exceptions MUST note the changes in
01441  * the 'DynamicStatic' struct.
01442  * Character pointer fields point to dynamic storage, unless otherwise stated.
01443  */
01444 
01445 struct Curl_multi;    /* declared and used only in multi.c */
01446 
01447 enum dupstring {
01448   STRING_CERT_ORIG,       /* client certificate file name */
01449   STRING_CERT_PROXY,      /* client certificate file name */
01450   STRING_CERT_TYPE_ORIG,  /* format for certificate (default: PEM)*/
01451   STRING_CERT_TYPE_PROXY, /* format for certificate (default: PEM)*/
01452   STRING_COOKIE,          /* HTTP cookie string to send */
01453   STRING_COOKIEJAR,       /* dump all cookies to this file */
01454   STRING_CUSTOMREQUEST,   /* HTTP/FTP/RTSP request/method to use */
01455   STRING_DEFAULT_PROTOCOL, /* Protocol to use when the URL doesn't specify */
01456   STRING_DEVICE,          /* local network interface/address to use */
01457   STRING_ENCODING,        /* Accept-Encoding string */
01458   STRING_FTP_ACCOUNT,     /* ftp account data */
01459   STRING_FTP_ALTERNATIVE_TO_USER, /* command to send if USER/PASS fails */
01460   STRING_FTPPORT,         /* port to send with the FTP PORT command */
01461   STRING_KEY_ORIG,        /* private key file name */
01462   STRING_KEY_PROXY,       /* private key file name */
01463   STRING_KEY_PASSWD_ORIG, /* plain text private key password */
01464   STRING_KEY_PASSWD_PROXY, /* plain text private key password */
01465   STRING_KEY_TYPE_ORIG,   /* format for private key (default: PEM) */
01466   STRING_KEY_TYPE_PROXY,  /* format for private key (default: PEM) */
01467   STRING_KRB_LEVEL,       /* krb security level */
01468   STRING_NETRC_FILE,      /* if not NULL, use this instead of trying to find
01469                              $HOME/.netrc */
01470   STRING_PROXY,           /* proxy to use */
01471   STRING_PRE_PROXY,       /* pre socks proxy to use */
01472   STRING_SET_RANGE,       /* range, if used */
01473   STRING_SET_REFERER,     /* custom string for the HTTP referer field */
01474   STRING_SET_URL,         /* what original URL to work on */
01475   STRING_SSL_CAPATH_ORIG, /* CA directory name (doesn't work on windows) */
01476   STRING_SSL_CAPATH_PROXY, /* CA directory name (doesn't work on windows) */
01477   STRING_SSL_CAFILE_ORIG, /* certificate file to verify peer against */
01478   STRING_SSL_CAFILE_PROXY, /* certificate file to verify peer against */
01479   STRING_SSL_PINNEDPUBLICKEY_ORIG, /* public key file to verify peer against */
01480   STRING_SSL_PINNEDPUBLICKEY_PROXY, /* public key file to verify proxy */
01481   STRING_SSL_CIPHER_LIST_ORIG, /* list of ciphers to use */
01482   STRING_SSL_CIPHER_LIST_PROXY, /* list of ciphers to use */
01483   STRING_SSL_EGDSOCKET,   /* path to file containing the EGD daemon socket */
01484   STRING_SSL_RANDOM_FILE, /* path to file containing "random" data */
01485   STRING_USERAGENT,       /* User-Agent string */
01486   STRING_SSL_CRLFILE_ORIG, /* crl file to check certificate */
01487   STRING_SSL_CRLFILE_PROXY, /* crl file to check certificate */
01488   STRING_SSL_ISSUERCERT_ORIG, /* issuer cert file to check certificate */
01489   STRING_SSL_ISSUERCERT_PROXY, /* issuer cert file to check certificate */
01490   STRING_USERNAME,        /* <username>, if used */
01491   STRING_PASSWORD,        /* <password>, if used */
01492   STRING_OPTIONS,         /* <options>, if used */
01493   STRING_PROXYUSERNAME,   /* Proxy <username>, if used */
01494   STRING_PROXYPASSWORD,   /* Proxy <password>, if used */
01495   STRING_NOPROXY,         /* List of hosts which should not use the proxy, if
01496                              used */
01497   STRING_RTSP_SESSION_ID, /* Session ID to use */
01498   STRING_RTSP_STREAM_URI, /* Stream URI for this request */
01499   STRING_RTSP_TRANSPORT,  /* Transport for this session */
01500 #ifdef USE_LIBSSH2
01501   STRING_SSH_PRIVATE_KEY, /* path to the private key file for auth */
01502   STRING_SSH_PUBLIC_KEY,  /* path to the public key file for auth */
01503   STRING_SSH_HOST_PUBLIC_KEY_MD5, /* md5 of host public key in ascii hex */
01504   STRING_SSH_KNOWNHOSTS,  /* file name of knownhosts file */
01505 #endif
01506 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
01507   STRING_PROXY_SERVICE_NAME, /* Proxy service name */
01508 #endif
01509 #if !defined(CURL_DISABLE_CRYPTO_AUTH) || defined(USE_KERBEROS5) || \
01510     defined(USE_SPNEGO)
01511   STRING_SERVICE_NAME,    /* Service name */
01512 #endif
01513   STRING_MAIL_FROM,
01514   STRING_MAIL_AUTH,
01515 
01516 #ifdef USE_TLS_SRP
01517   STRING_TLSAUTH_USERNAME_ORIG,  /* TLS auth <username> */
01518   STRING_TLSAUTH_USERNAME_PROXY, /* TLS auth <username> */
01519   STRING_TLSAUTH_PASSWORD_ORIG,  /* TLS auth <password> */
01520   STRING_TLSAUTH_PASSWORD_PROXY, /* TLS auth <password> */
01521 #endif
01522   STRING_BEARER,                /* <bearer>, if used */
01523 #ifdef USE_UNIX_SOCKETS
01524   STRING_UNIX_SOCKET_PATH,      /* path to Unix socket, if used */
01525 #endif
01526 
01527   /* -- end of zero-terminated strings -- */
01528 
01529   STRING_LASTZEROTERMINATED,
01530 
01531   /* -- below this are pointers to binary data that cannot be strdup'ed.
01532      Each such pointer must be added manually to Curl_dupset() --- */
01533 
01534   STRING_COPYPOSTFIELDS,  /* if POST, set the fields' values here */
01535 
01536   STRING_LAST /* not used, just an end-of-list marker */
01537 };
01538 
01539 struct UserDefined {
01540   FILE *err;         /* the stderr user data goes here */
01541   void *debugdata;   /* the data that will be passed to fdebug */
01542   char *errorbuffer; /* (Static) store failure messages in here */
01543   long proxyport; /* If non-zero, use this port number by default. If the
01544                      proxy string features a ":[port]" that one will override
01545                      this. */
01546   void *out;         /* CURLOPT_WRITEDATA */
01547   void *in_set;      /* CURLOPT_READDATA */
01548   void *writeheader; /* write the header to this if non-NULL */
01549   void *rtp_out;     /* write RTP to this if non-NULL */
01550   long use_port;     /* which port to use (when not using default) */
01551   unsigned long httpauth;  /* kind of HTTP authentication to use (bitmask) */
01552   unsigned long proxyauth; /* kind of proxy authentication to use (bitmask) */
01553   long followlocation; /* as in HTTP Location: */
01554   long maxredirs;    /* maximum no. of http(s) redirects to follow, set to -1
01555                         for infinity */
01556 
01557   int keep_post;     /* keep POSTs as POSTs after a 30x request; each
01558                         bit represents a request, from 301 to 303 */
01559   bool free_referer; /* set TRUE if 'referer' points to a string we
01560                         allocated */
01561   void *postfields;  /* if POST, set the fields' values here */
01562   curl_seek_callback seek_func;      /* function that seeks the input */
01563   curl_off_t postfieldsize; /* if POST, this might have a size to use instead
01564                                of strlen(), and then the data *may* be binary
01565                                (contain zero bytes) */
01566   unsigned short localport; /* local port number to bind to */
01567   int localportrange; /* number of additional port numbers to test in case the
01568                          'localport' one can't be bind()ed */
01569   curl_write_callback fwrite_func;   /* function that stores the output */
01570   curl_write_callback fwrite_header; /* function that stores headers */
01571   curl_write_callback fwrite_rtp;    /* function that stores interleaved RTP */
01572   curl_read_callback fread_func_set; /* function that reads the input */
01573   int is_fread_set; /* boolean, has read callback been set to non-NULL? */
01574   int is_fwrite_set; /* boolean, has write callback been set to non-NULL? */
01575   curl_progress_callback fprogress; /* OLD and deprecated progress callback  */
01576   curl_xferinfo_callback fxferinfo; /* progress callback */
01577   curl_debug_callback fdebug;      /* function that write informational data */
01578   curl_ioctl_callback ioctl_func;  /* function for I/O control */
01579   curl_sockopt_callback fsockopt;  /* function for setting socket options */
01580   void *sockopt_client; /* pointer to pass to the socket options callback */
01581   curl_opensocket_callback fopensocket; /* function for checking/translating
01582                                            the address and opening the
01583                                            socket */
01584   void *opensocket_client;
01585   curl_closesocket_callback fclosesocket; /* function for closing the
01586                                              socket */
01587   void *closesocket_client;
01588 
01589   void *seek_client;    /* pointer to pass to the seek callback */
01590   /* the 3 curl_conv_callback functions below are used on non-ASCII hosts */
01591   /* function to convert from the network encoding: */
01592   curl_conv_callback convfromnetwork;
01593   /* function to convert to the network encoding: */
01594   curl_conv_callback convtonetwork;
01595   /* function to convert from UTF-8 encoding: */
01596   curl_conv_callback convfromutf8;
01597 
01598   void *progress_client; /* pointer to pass to the progress callback */
01599   void *ioctl_client;   /* pointer to pass to the ioctl callback */
01600   long timeout;         /* in milliseconds, 0 means no timeout */
01601   long connecttimeout;  /* in milliseconds, 0 means no timeout */
01602   long accepttimeout;   /* in milliseconds, 0 means no timeout */
01603   long server_response_timeout; /* in milliseconds, 0 means no timeout */
01604   long tftp_blksize;    /* in bytes, 0 means use default */
01605   bool tftp_no_options; /* do not send TFTP options requests */
01606   curl_off_t filesize;  /* size of file to upload, -1 means unknown */
01607   long low_speed_limit; /* bytes/second */
01608   long low_speed_time;  /* number of seconds */
01609   curl_off_t max_send_speed; /* high speed limit in bytes/second for upload */
01610   curl_off_t max_recv_speed; /* high speed limit in bytes/second for
01611                                 download */
01612   curl_off_t set_resume_from;  /* continue [ftp] transfer from here */
01613   struct curl_slist *headers; /* linked list of extra headers */
01614   struct curl_slist *proxyheaders; /* linked list of extra CONNECT headers */
01615   struct curl_httppost *httppost;  /* linked list of POST data */
01616   bool sep_headers;     /* handle host and proxy headers separately */
01617   bool cookiesession;   /* new cookie session? */
01618   bool crlf;            /* convert crlf on ftp upload(?) */
01619   struct curl_slist *quote;     /* after connection is established */
01620   struct curl_slist *postquote; /* after the transfer */
01621   struct curl_slist *prequote; /* before the transfer, after type */
01622   struct curl_slist *source_quote;  /* 3rd party quote */
01623   struct curl_slist *source_prequote;  /* in 3rd party transfer mode - before
01624                                           the transfer on source host */
01625   struct curl_slist *source_postquote; /* in 3rd party transfer mode - after
01626                                           the transfer on source host */
01627   struct curl_slist *telnet_options; /* linked list of telnet options */
01628   struct curl_slist *resolve;     /* list of names to add/remove from
01629                                      DNS cache */
01630   struct curl_slist *connect_to; /* list of host:port mappings to override
01631                                     the hostname and port to connect to */
01632   curl_TimeCond timecondition; /* kind of time/date comparison */
01633   time_t timevalue;       /* what time to compare with */
01634   Curl_HttpReq httpreq;   /* what kind of HTTP request (if any) is this */
01635   long httpversion; /* when non-zero, a specific HTTP version requested to
01636                        be used in the library's request(s) */
01637   struct ssl_config_data ssl;  /* user defined SSL stuff */
01638   struct ssl_config_data proxy_ssl;  /* user defined SSL stuff for proxy */
01639   struct ssl_general_config general_ssl; /* general user defined SSL stuff */
01640   curl_proxytype proxytype; /* what kind of proxy that is in use */
01641   curl_proxytype socks_proxytype; /* what kind of socks proxy that is in use */
01642   long dns_cache_timeout; /* DNS cache timeout */
01643   long buffer_size;      /* size of receive buffer to use */
01644   void *private_data; /* application-private data */
01645 
01646   struct curl_slist *http200aliases; /* linked list of aliases for http200 */
01647 
01648   long ipver; /* the CURL_IPRESOLVE_* defines in the public header file
01649                  0 - whatever, 1 - v2, 2 - v6 */
01650 
01651   curl_off_t max_filesize; /* Maximum file size to download */
01652 
01653   curl_ftpfile ftp_filemethod; /* how to get to a file when FTP is used  */
01654 
01655   int ftp_create_missing_dirs; /* 1 - create directories that don't exist
01656                                   2 - the same but also allow MKD to fail once
01657                                */
01658 
01659   curl_sshkeycallback ssh_keyfunc; /* key matching callback */
01660   void *ssh_keyfunc_userp;         /* custom pointer to callback */
01661 
01662 /* Here follows boolean settings that define how to behave during
01663    this session. They are STATIC, set by libcurl users or at least initially
01664    and they don't change during operations. */
01665 
01666   bool printhost;        /* printing host name in debug info */
01667   bool get_filetime;     /* get the time and get of the remote file */
01668   bool tunnel_thru_httpproxy; /* use CONNECT through a HTTP proxy */
01669   bool prefer_ascii;     /* ASCII rather than binary */
01670   bool ftp_append;       /* append, not overwrite, on upload */
01671   bool ftp_list_only;    /* switch FTP command for listing directories */
01672   bool ftp_use_port;     /* use the FTP PORT command */
01673   bool hide_progress;    /* don't use the progress meter */
01674   bool http_fail_on_error;  /* fail on HTTP error codes >= 400 */
01675   bool http_keep_sending_on_error; /* for HTTP status codes >= 300 */
01676   bool http_follow_location; /* follow HTTP redirects */
01677   bool http_transfer_encoding; /* request compressed HTTP transfer-encoding */
01678   bool http_disable_hostname_check_before_authentication;
01679   bool include_header;   /* include received protocol headers in data output */
01680   bool http_set_referer; /* is a custom referer used */
01681   bool http_auto_referer; /* set "correct" referer when following location: */
01682   bool opt_no_body;      /* as set with CURLOPT_NOBODY */
01683   bool upload;           /* upload request */
01684   enum CURL_NETRC_OPTION
01685        use_netrc;        /* defined in include/curl.h */
01686   bool verbose;          /* output verbosity */
01687   bool krb;              /* Kerberos connection requested */
01688   bool reuse_forbid;     /* forbidden to be reused, close after use */
01689   bool reuse_fresh;      /* do not re-use an existing connection  */
01690   bool ftp_use_epsv;     /* if EPSV is to be attempted or not */
01691   bool ftp_use_eprt;     /* if EPRT is to be attempted or not */
01692   bool ftp_use_pret;     /* if PRET is to be used before PASV or not */
01693 
01694   curl_usessl use_ssl;   /* if AUTH TLS is to be attempted etc, for FTP or
01695                             IMAP or POP3 or others! */
01696   curl_ftpauth ftpsslauth; /* what AUTH XXX to be attempted */
01697   curl_ftpccc ftp_ccc;   /* FTP CCC options */
01698   bool no_signal;        /* do not use any signal/alarm handler */
01699   bool global_dns_cache; /* subject for future removal */
01700   bool tcp_nodelay;      /* whether to enable TCP_NODELAY or not */
01701   bool ignorecl;         /* ignore content length */
01702   bool ftp_skip_ip;      /* skip the IP address the FTP server passes on to
01703                             us */
01704   bool connect_only;     /* make connection, let application use the socket */
01705   long ssh_auth_types;   /* allowed SSH auth types */
01706   bool http_te_skip;     /* pass the raw body data to the user, even when
01707                             transfer-encoded (chunked, compressed) */
01708   bool http_ce_skip;     /* pass the raw body data to the user, even when
01709                             content-encoded (chunked, compressed) */
01710   long new_file_perms;    /* Permissions to use when creating remote files */
01711   long new_directory_perms; /* Permissions to use when creating remote dirs */
01712   bool proxy_transfer_mode; /* set transfer mode (;type=<a|i>) when doing FTP
01713                                via an HTTP proxy */
01714   char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */
01715   unsigned int scope_id;  /* Scope id for IPv6 */
01716   long allowed_protocols;
01717   long redir_protocols;
01718 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
01719   bool socks5_gssapi_nec; /* Flag to support NEC SOCKS5 server */
01720 #endif
01721   struct curl_slist *mail_rcpt; /* linked list of mail recipients */
01722   bool sasl_ir;         /* Enable/disable SASL initial response */
01723   /* Common RTSP header options */
01724   Curl_RtspReq rtspreq; /* RTSP request type */
01725   long rtspversion; /* like httpversion, for RTSP */
01726   bool wildcardmatch; /* enable wildcard matching */
01727   curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer
01728                                         starts */
01729   curl_chunk_end_callback chunk_end; /* called after part transferring
01730                                         stopped */
01731   curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds
01732                                     to pattern (e.g. if WILDCARDMATCH is on) */
01733   void *fnmatch_data;
01734 
01735   long gssapi_delegation; /* GSS-API credential delegation, see the
01736                              documentation of CURLOPT_GSSAPI_DELEGATION */
01737 
01738   bool tcp_keepalive;    /* use TCP keepalives */
01739   long tcp_keepidle;     /* seconds in idle before sending keepalive probe */
01740   long tcp_keepintvl;    /* seconds between TCP keepalive probes */
01741   bool tcp_fastopen;     /* use TCP Fast Open */
01742 
01743   size_t maxconnects;  /* Max idle connections in the connection cache */
01744 
01745   bool ssl_enable_npn;      /* TLS NPN extension? */
01746   bool ssl_enable_alpn;     /* TLS ALPN extension? */
01747   bool path_as_is;      /* allow dotdots? */
01748   bool pipewait;        /* wait for pipe/multiplex status before starting a
01749                            new connection */
01750   long expect_100_timeout; /* in milliseconds */
01751 
01752   struct Curl_easy *stream_depends_on;
01753   bool stream_depends_e; /* set or don't set the Exclusive bit */
01754   int stream_weight;
01755 
01756   struct Curl_http2_dep *stream_dependents;
01757 };
01758 
01759 struct Names {
01760   struct curl_hash *hostcache;
01761   enum {
01762     HCACHE_NONE,    /* not pointing to anything */
01763     HCACHE_GLOBAL,  /* points to the (shrug) global one */
01764     HCACHE_MULTI,   /* points to a shared one in the multi handle */
01765     HCACHE_SHARED   /* points to a shared one in a shared object */
01766   } hostcachetype;
01767 };
01768 
01769 /*
01770  * The 'connectdata' struct MUST have all the connection oriented stuff as we
01771  * may have several simultaneous connections and connection structs in memory.
01772  *
01773  * The 'struct UserDefined' must only contain data that is set once to go for
01774  * many (perhaps) independent connections. Values that are generated or
01775  * calculated internally for the "session handle" must be defined within the
01776  * 'struct UrlState' instead.
01777  */
01778 
01779 struct Curl_easy {
01780   /* first, two fields for the linked list of these */
01781   struct Curl_easy *next;
01782   struct Curl_easy *prev;
01783 
01784   struct connectdata *easy_conn;     /* the "unit's" connection */
01785 
01786   CURLMstate mstate;  /* the handle's state */
01787   CURLcode result;   /* previous result */
01788 
01789   struct Curl_message msg; /* A single posted message. */
01790 
01791   /* Array with the plain socket numbers this handle takes care of, in no
01792      particular order. Note that all sockets are added to the sockhash, where
01793      the state etc are also kept. This array is mostly used to detect when a
01794      socket is to be removed from the hash. See singlesocket(). */
01795   curl_socket_t sockets[MAX_SOCKSPEREASYHANDLE];
01796   int numsocks;
01797 
01798   struct Names dns;
01799   struct Curl_multi *multi;    /* if non-NULL, points to the multi handle
01800                                   struct to which this "belongs" when used by
01801                                   the multi interface */
01802   struct Curl_multi *multi_easy; /* if non-NULL, points to the multi handle
01803                                     struct to which this "belongs" when used
01804                                     by the easy interface */
01805   struct Curl_share *share;    /* Share, handles global variable mutexing */
01806   struct SingleRequest req;    /* Request-specific data */
01807   struct UserDefined set;      /* values set by the libcurl user */
01808   struct DynamicStatic change; /* possibly modified userdefined data */
01809   struct CookieInfo *cookies;  /* the cookies, read from files and servers.
01810                                   NOTE that the 'cookie' field in the
01811                                   UserDefined struct defines if the "engine"
01812                                   is to be used or not. */
01813   struct Progress progress;    /* for all the progress meter data */
01814   struct UrlState state;       /* struct for fields used for state info and
01815                                   other dynamic purposes */
01816   struct WildcardData wildcard; /* wildcard download state info */
01817   struct PureInfo info;        /* stats, reports and info data */
01818   struct curl_tlssessioninfo tsi; /* Information about the TLS session, only
01819                                      valid after a client has asked for it */
01820 #if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
01821   iconv_t outbound_cd;         /* for translating to the network encoding */
01822   iconv_t inbound_cd;          /* for translating from the network encoding */
01823   iconv_t utf8_cd;             /* for translating to UTF8 */
01824 #endif /* CURL_DOES_CONVERSIONS && HAVE_ICONV */
01825   unsigned int magic;          /* set to a CURLEASY_MAGIC_NUMBER */
01826 };
01827 
01828 #define LIBCURL_NAME "libcurl"
01829 
01830 #endif /* HEADER_CURL_URLDATA_H */


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:07