Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1 | #ifndef HEADER_CURL_URLDATA_H |
| 2 | #define HEADER_CURL_URLDATA_H |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 3 | /*************************************************************************** |
| 4 | * _ _ ____ _ |
| 5 | * Project ___| | | | _ \| | |
| 6 | * / __| | | | |_) | | |
| 7 | * | (__| |_| | _ <| |___ |
| 8 | * \___|\___/|_| \_\_____| |
| 9 | * |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 10 | * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 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 |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 14 | * are also available at https://curl.haxx.se/docs/copyright.html. |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 15 | * |
| 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 17 | * copies of the Software, and permit persons to whom the Software is |
| 18 | * furnished to do so, under the terms of the COPYING file. |
| 19 | * |
| 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 21 | * KIND, either express or implied. |
| 22 | * |
| 23 | ***************************************************************************/ |
| 24 | |
| 25 | /* This file is for lib internal stuff */ |
| 26 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 27 | #include "curl_setup.h" |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 28 | |
| 29 | #define PORT_FTP 21 |
| 30 | #define PORT_FTPS 990 |
| 31 | #define PORT_TELNET 23 |
| 32 | #define PORT_HTTP 80 |
| 33 | #define PORT_HTTPS 443 |
| 34 | #define PORT_DICT 2628 |
| 35 | #define PORT_LDAP 389 |
| 36 | #define PORT_LDAPS 636 |
| 37 | #define PORT_TFTP 69 |
| 38 | #define PORT_SSH 22 |
| 39 | #define PORT_IMAP 143 |
| 40 | #define PORT_IMAPS 993 |
| 41 | #define PORT_POP3 110 |
| 42 | #define PORT_POP3S 995 |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 43 | #define PORT_SMB 445 |
| 44 | #define PORT_SMBS 445 |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 45 | #define PORT_SMTP 25 |
| 46 | #define PORT_SMTPS 465 /* sometimes called SSMTP */ |
| 47 | #define PORT_RTSP 554 |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 48 | #define PORT_RTMP 1935 |
| 49 | #define PORT_RTMPT PORT_HTTP |
| 50 | #define PORT_RTMPS PORT_HTTPS |
| 51 | #define PORT_GOPHER 70 |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 52 | |
| 53 | #define DICT_MATCH "/MATCH:" |
| 54 | #define DICT_MATCH2 "/M:" |
| 55 | #define DICT_MATCH3 "/FIND:" |
| 56 | #define DICT_DEFINE "/DEFINE:" |
| 57 | #define DICT_DEFINE2 "/D:" |
| 58 | #define DICT_DEFINE3 "/LOOKUP:" |
| 59 | |
| 60 | #define CURL_DEFAULT_USER "anonymous" |
| 61 | #define CURL_DEFAULT_PASSWORD "ftp@example.com" |
| 62 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 63 | /* Convenience defines for checking protocols or their SSL based version. Each |
| 64 | protocol handler should only ever have a single CURLPROTO_ in its protocol |
| 65 | field. */ |
| 66 | #define PROTO_FAMILY_HTTP (CURLPROTO_HTTP|CURLPROTO_HTTPS) |
| 67 | #define PROTO_FAMILY_FTP (CURLPROTO_FTP|CURLPROTO_FTPS) |
| 68 | #define PROTO_FAMILY_POP3 (CURLPROTO_POP3|CURLPROTO_POP3S) |
| 69 | #define PROTO_FAMILY_SMB (CURLPROTO_SMB|CURLPROTO_SMBS) |
| 70 | #define PROTO_FAMILY_SMTP (CURLPROTO_SMTP|CURLPROTO_SMTPS) |
| 71 | |
| 72 | #define DEFAULT_CONNCACHE_SIZE 5 |
| 73 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 74 | /* length of longest IPv6 address string including the trailing null */ |
| 75 | #define MAX_IPADR_LEN sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") |
| 76 | |
| 77 | /* Default FTP/IMAP etc response timeout in milliseconds. |
| 78 | Symbian OS panics when given a timeout much greater than 1/2 hour. |
| 79 | */ |
| 80 | #define RESP_TIMEOUT (1800*1000) |
| 81 | |
| 82 | #include "cookie.h" |
| 83 | #include "formdata.h" |
| 84 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 85 | #ifdef HAVE_NETINET_IN_H |
| 86 | #include <netinet/in.h> |
| 87 | #endif |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 88 | #ifdef HAVE_NETINET_IN6_H |
| 89 | #include <netinet/in6.h> |
| 90 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 91 | |
| 92 | #include "timeval.h" |
| 93 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 94 | #include <curl/curl.h> |
| 95 | |
| 96 | #include "http_chunks.h" /* for the structs and enum stuff */ |
| 97 | #include "hostip.h" |
| 98 | #include "hash.h" |
| 99 | #include "splay.h" |
| 100 | |
Elliott Hughes | 1ef06ba | 2018-05-30 15:43:58 -0700 | [diff] [blame] | 101 | /* return the count of bytes sent, or -1 on error */ |
| 102 | typedef ssize_t (Curl_send)(struct connectdata *conn, /* connection data */ |
| 103 | int sockindex, /* socketindex */ |
| 104 | const void *buf, /* data to write */ |
| 105 | size_t len, /* max amount to write */ |
| 106 | CURLcode *err); /* error to return */ |
| 107 | |
| 108 | /* return the count of bytes read, or -1 on error */ |
| 109 | typedef ssize_t (Curl_recv)(struct connectdata *conn, /* connection data */ |
| 110 | int sockindex, /* socketindex */ |
| 111 | char *buf, /* store data here */ |
| 112 | size_t len, /* max amount to read */ |
| 113 | CURLcode *err); /* error to return */ |
| 114 | |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 115 | #include "mime.h" |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 116 | #include "imap.h" |
| 117 | #include "pop3.h" |
| 118 | #include "smtp.h" |
| 119 | #include "ftp.h" |
| 120 | #include "file.h" |
| 121 | #include "ssh.h" |
| 122 | #include "http.h" |
| 123 | #include "rtsp.h" |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 124 | #include "smb.h" |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 125 | #include "wildcard.h" |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 126 | #include "multihandle.h" |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 127 | |
| 128 | #ifdef HAVE_GSSAPI |
| 129 | # ifdef HAVE_GSSGNU |
| 130 | # include <gss.h> |
| 131 | # elif defined HAVE_GSSMIT |
| 132 | # include <gssapi/gssapi.h> |
| 133 | # include <gssapi/gssapi_generic.h> |
| 134 | # else |
| 135 | # include <gssapi.h> |
| 136 | # endif |
| 137 | #endif |
| 138 | |
| 139 | #ifdef HAVE_LIBSSH2_H |
| 140 | #include <libssh2.h> |
| 141 | #include <libssh2_sftp.h> |
| 142 | #endif /* HAVE_LIBSSH2_H */ |
| 143 | |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 144 | /* The upload buffer size, should not be smaller than CURL_MAX_WRITE_SIZE, as |
| 145 | it needs to hold a full buffer as could be sent in a write callback */ |
| 146 | #define UPLOAD_BUFSIZE CURL_MAX_WRITE_SIZE |
| 147 | |
| 148 | /* The "master buffer" is for HTTP pipelining */ |
| 149 | #define MASTERBUF_SIZE 16384 |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 150 | |
| 151 | /* Initial size of the buffer to store headers in, it'll be enlarged in case |
| 152 | of need. */ |
| 153 | #define HEADERSIZE 256 |
| 154 | |
| 155 | #define CURLEASY_MAGIC_NUMBER 0xc0dedbadU |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 156 | #define GOOD_EASY_HANDLE(x) \ |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 157 | ((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER)) |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 158 | |
| 159 | /* Some convenience macros to get the larger/smaller value out of two given. |
| 160 | We prefix with CURL to prevent name collisions. */ |
| 161 | #define CURLMAX(x,y) ((x)>(y)?(x):(y)) |
| 162 | #define CURLMIN(x,y) ((x)<(y)?(x):(y)) |
| 163 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 164 | #ifdef HAVE_GSSAPI |
| 165 | /* Types needed for krb5-ftp connections */ |
| 166 | struct krb5buffer { |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 167 | void *data; |
| 168 | size_t size; |
| 169 | size_t index; |
| 170 | int eof_flag; |
| 171 | }; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 172 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 173 | enum protection_level { |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 174 | PROT_NONE, /* first in list */ |
| 175 | PROT_CLEAR, |
| 176 | PROT_SAFE, |
| 177 | PROT_CONFIDENTIAL, |
| 178 | PROT_PRIVATE, |
| 179 | PROT_CMD, |
| 180 | PROT_LAST /* last in list */ |
| 181 | }; |
| 182 | #endif |
| 183 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 184 | /* enum for the nonblocking SSL connection state machine */ |
| 185 | typedef enum { |
| 186 | ssl_connect_1, |
| 187 | ssl_connect_2, |
| 188 | ssl_connect_2_reading, |
| 189 | ssl_connect_2_writing, |
| 190 | ssl_connect_3, |
| 191 | ssl_connect_done |
| 192 | } ssl_connect_state; |
| 193 | |
| 194 | typedef enum { |
| 195 | ssl_connection_none, |
| 196 | ssl_connection_negotiating, |
| 197 | ssl_connection_complete |
| 198 | } ssl_connection_state; |
| 199 | |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 200 | /* SSL backend-specific data; declared differently by each SSL backend */ |
| 201 | struct ssl_backend_data; |
| 202 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 203 | /* struct for data related to each SSL connection */ |
| 204 | struct ssl_connect_data { |
| 205 | /* Use ssl encrypted communications TRUE/FALSE, not necessarily using it atm |
| 206 | but at least asked to or meaning to use it. See 'state' for the exact |
| 207 | current state of the connection. */ |
| 208 | bool use; |
| 209 | ssl_connection_state state; |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 210 | ssl_connect_state connecting_state; |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 211 | #if defined(USE_SSL) |
| 212 | struct ssl_backend_data *backend; |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 213 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 214 | }; |
| 215 | |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 216 | struct ssl_primary_config { |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 217 | long version; /* what version the client wants to use */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 218 | long version_max; /* max supported version the client wants to use*/ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 219 | bool verifypeer; /* set TRUE if this is desired */ |
| 220 | bool verifyhost; /* set TRUE if CN/SAN must match hostname */ |
| 221 | bool verifystatus; /* set TRUE if certificate status must be checked */ |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 222 | bool sessionid; /* cache session IDs or not */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 223 | char *CApath; /* certificate dir (doesn't work on windows) */ |
| 224 | char *CAfile; /* certificate to verify peer against */ |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 225 | char *clientcert; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 226 | char *random_file; /* path to file containing "random" data */ |
| 227 | char *egdsocket; /* path to file containing the EGD daemon socket */ |
| 228 | char *cipher_list; /* list of ciphers to use */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 229 | }; |
| 230 | |
| 231 | struct ssl_config_data { |
| 232 | struct ssl_primary_config primary; |
| 233 | bool enable_beast; /* especially allow this flaw for interoperability's |
| 234 | sake*/ |
| 235 | bool no_revoke; /* disable SSL certificate revocation checks */ |
| 236 | long certverifyresult; /* result from the certificate verification */ |
| 237 | char *CRLfile; /* CRL to check certificate revocation */ |
| 238 | char *issuercert;/* optional issuer certificate filename */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 239 | curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */ |
| 240 | void *fsslctxp; /* parameter for call back */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 241 | bool certinfo; /* gather lots of certificate info */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 242 | bool falsestart; |
| 243 | |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 244 | char *cert; /* client certificate file name */ |
| 245 | char *cert_type; /* format for certificate (default: PEM)*/ |
| 246 | char *key; /* private key file name */ |
| 247 | char *key_type; /* format for private key (default: PEM) */ |
| 248 | char *key_passwd; /* plain text private key password */ |
| 249 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 250 | #ifdef USE_TLS_SRP |
| 251 | char *username; /* TLS username (for, e.g., SRP) */ |
| 252 | char *password; /* TLS password (for, e.g., SRP) */ |
| 253 | enum CURL_TLSAUTH authtype; /* TLS authentication type (default SRP) */ |
| 254 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 255 | }; |
| 256 | |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 257 | struct ssl_general_config { |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 258 | size_t max_ssl_sessions; /* SSL session id cache size */ |
| 259 | }; |
| 260 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 261 | /* information stored about one single SSL session */ |
| 262 | struct curl_ssl_session { |
| 263 | char *name; /* host name for which this ID was used */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 264 | char *conn_to_host; /* host name for the connection (may be NULL) */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 265 | const char *scheme; /* protocol scheme used */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 266 | void *sessionid; /* as returned from the SSL layer */ |
| 267 | size_t idsize; /* if known, otherwise 0 */ |
| 268 | long age; /* just a number, the higher the more recent */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 269 | int remote_port; /* remote port */ |
| 270 | int conn_to_port; /* remote port for the connection (may be -1) */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 271 | struct ssl_primary_config ssl_config; /* setup for this session */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 272 | }; |
| 273 | |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 274 | #ifdef USE_WINDOWS_SSPI |
| 275 | #include "curl_sspi.h" |
| 276 | #endif |
| 277 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 278 | /* Struct used for Digest challenge-response authentication */ |
| 279 | struct digestdata { |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 280 | #if defined(USE_WINDOWS_SSPI) |
| 281 | BYTE *input_token; |
| 282 | size_t input_token_len; |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 283 | CtxtHandle *http_context; |
| 284 | /* copy of user/passwd used to make the identity for http_context. |
| 285 | either may be NULL. */ |
| 286 | char *user; |
| 287 | char *passwd; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 288 | #else |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 289 | char *nonce; |
| 290 | char *cnonce; |
| 291 | char *realm; |
| 292 | int algo; |
| 293 | bool stale; /* set true for re-negotiation */ |
| 294 | char *opaque; |
| 295 | char *qop; |
| 296 | char *algorithm; |
| 297 | int nc; /* nounce count */ |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 298 | bool userhash; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 299 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 300 | }; |
| 301 | |
| 302 | typedef enum { |
| 303 | NTLMSTATE_NONE, |
| 304 | NTLMSTATE_TYPE1, |
| 305 | NTLMSTATE_TYPE2, |
| 306 | NTLMSTATE_TYPE3, |
| 307 | NTLMSTATE_LAST |
| 308 | } curlntlm; |
| 309 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 310 | #if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV) |
| 311 | #include <iconv.h> |
| 312 | #endif |
| 313 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 314 | /* Struct used for GSSAPI (Kerberos V5) authentication */ |
| 315 | #if defined(USE_KERBEROS5) |
| 316 | struct kerberos5data { |
| 317 | #if defined(USE_WINDOWS_SSPI) |
| 318 | CredHandle *credentials; |
| 319 | CtxtHandle *context; |
| 320 | TCHAR *spn; |
| 321 | SEC_WINNT_AUTH_IDENTITY identity; |
| 322 | SEC_WINNT_AUTH_IDENTITY *p_identity; |
| 323 | size_t token_max; |
| 324 | BYTE *output_token; |
| 325 | #else |
| 326 | gss_ctx_id_t context; |
| 327 | gss_name_t spn; |
| 328 | #endif |
| 329 | }; |
| 330 | #endif |
| 331 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 332 | /* Struct used for NTLM challenge-response authentication */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 333 | #if defined(USE_NTLM) |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 334 | struct ntlmdata { |
| 335 | curlntlm state; |
| 336 | #ifdef USE_WINDOWS_SSPI |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 337 | CredHandle *credentials; |
| 338 | CtxtHandle *context; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 339 | SEC_WINNT_AUTH_IDENTITY identity; |
| 340 | SEC_WINNT_AUTH_IDENTITY *p_identity; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 341 | size_t token_max; |
| 342 | BYTE *output_token; |
| 343 | BYTE *input_token; |
| 344 | size_t input_token_len; |
Elliott Hughes | 1ef06ba | 2018-05-30 15:43:58 -0700 | [diff] [blame] | 345 | TCHAR *spn; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 346 | #else |
| 347 | unsigned int flags; |
| 348 | unsigned char nonce[8]; |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 349 | void *target_info; /* TargetInfo received in the ntlm type-2 message */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 350 | unsigned int target_info_len; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 351 | #endif |
| 352 | }; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 353 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 354 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 355 | #ifdef USE_SPNEGO |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 356 | struct negotiatedata { |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 357 | /* When doing Negotiate (SPNEGO) auth, we first need to send a token |
| 358 | and then validate the received one. */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 359 | enum { GSS_AUTHNONE, GSS_AUTHRECV, GSS_AUTHSENT } state; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 360 | #ifdef HAVE_GSSAPI |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 361 | OM_uint32 status; |
| 362 | gss_ctx_id_t context; |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 363 | gss_name_t spn; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 364 | gss_buffer_desc output_token; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 365 | #else |
| 366 | #ifdef USE_WINDOWS_SSPI |
| 367 | DWORD status; |
| 368 | CredHandle *credentials; |
| 369 | CtxtHandle *context; |
| 370 | SEC_WINNT_AUTH_IDENTITY identity; |
| 371 | SEC_WINNT_AUTH_IDENTITY *p_identity; |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 372 | TCHAR *spn; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 373 | size_t token_max; |
| 374 | BYTE *output_token; |
| 375 | size_t output_token_length; |
| 376 | #endif |
| 377 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 378 | }; |
| 379 | #endif |
| 380 | |
| 381 | |
| 382 | /* |
| 383 | * Boolean values that concerns this connection. |
| 384 | */ |
| 385 | struct ConnectBits { |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 386 | /* always modify bits.close with the connclose() and connkeep() macros! */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 387 | bool close; /* if set, we close the connection after this request */ |
| 388 | bool reuse; /* if set, this is a re-used connection */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 389 | bool conn_to_host; /* if set, this connection has a "connect to host" |
| 390 | that overrides the host in the URL */ |
| 391 | bool conn_to_port; /* if set, this connection has a "connect to port" |
| 392 | that overrides the port in the URL (remote port) */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 393 | bool proxy; /* if set, this transfer is done through a proxy - any type */ |
| 394 | bool httpproxy; /* if set, this transfer is done through a http proxy */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 395 | bool socksproxy; /* if set, this transfer is done through a socks proxy */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 396 | bool user_passwd; /* do we use user+password for this connection? */ |
| 397 | bool proxy_user_passwd; /* user+password for the proxy? */ |
| 398 | bool ipv6_ip; /* we communicate with a remote site specified with pure IPv6 |
| 399 | IP address */ |
| 400 | bool ipv6; /* we communicate with a site using an IPv6 address */ |
| 401 | |
| 402 | bool do_more; /* this is set TRUE if the ->curl_do_more() function is |
| 403 | supposed to be called, after ->curl_do() */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 404 | bool tcpconnect[2]; /* the TCP layer (or similar) is connected, this is set |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 405 | the first time on the first connect function call */ |
| 406 | bool protoconnstart;/* the protocol layer has STARTED its operation after |
| 407 | the TCP layer connect */ |
| 408 | |
| 409 | bool retry; /* this connection is about to get closed and then |
| 410 | re-attempted at another connection. */ |
| 411 | bool tunnel_proxy; /* if CONNECT is used to "tunnel" through the proxy. |
| 412 | This is implicit when SSL-protocols are used through |
| 413 | proxies, but can also be enabled explicitly by |
| 414 | apps */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 415 | bool authneg; /* TRUE when the auth phase has started, which means |
| 416 | that we are creating a request with an auth header, |
| 417 | but it is not the final request in the auth |
| 418 | negotiation. */ |
| 419 | bool rewindaftersend;/* TRUE when the sending couldn't be stopped even |
| 420 | though it will be discarded. When the whole send |
| 421 | operation is done, we must call the data rewind |
| 422 | callback. */ |
| 423 | bool ftp_use_epsv; /* As set with CURLOPT_FTP_USE_EPSV, but if we find out |
| 424 | EPSV doesn't work we disable it for the forthcoming |
| 425 | requests */ |
| 426 | |
| 427 | bool ftp_use_eprt; /* As set with CURLOPT_FTP_USE_EPRT, but if we find out |
| 428 | EPRT doesn't work we disable it for the forthcoming |
| 429 | requests */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 430 | bool ftp_use_data_ssl; /* Enabled SSL for the data connection */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 431 | bool netrc; /* name+password provided by netrc */ |
| 432 | bool userpwd_in_url; /* name+password found in url */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 433 | bool stream_was_rewound; /* Indicates that the stream was rewound after a |
| 434 | request read past the end of its response byte |
| 435 | boundary */ |
| 436 | bool proxy_connect_closed; /* set true if a proxy disconnected the |
| 437 | connection in a CONNECT request with auth, so |
| 438 | that libcurl should reconnect and continue. */ |
| 439 | bool bound; /* set true if bind() has already been done on this socket/ |
| 440 | connection */ |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 441 | bool type_set; /* type= was used in the URL */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 442 | bool multiplex; /* connection is multiplexed */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 443 | |
| 444 | bool tcp_fastopen; /* use TCP Fast Open */ |
| 445 | bool tls_enable_npn; /* TLS NPN extension? */ |
| 446 | bool tls_enable_alpn; /* TLS ALPN extension? */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 447 | bool proxy_ssl_connected[2]; /* TRUE when SSL initialization for HTTPS proxy |
| 448 | is complete */ |
| 449 | bool socksproxy_connecting; /* connecting through a socks proxy */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 450 | }; |
| 451 | |
| 452 | struct hostname { |
| 453 | char *rawalloc; /* allocated "raw" version of the name */ |
| 454 | char *encalloc; /* allocated IDN-encoded version of the name */ |
| 455 | char *name; /* name to use internally, might be encoded, might be raw */ |
| 456 | const char *dispname; /* name to display, as 'name' might be encoded */ |
| 457 | }; |
| 458 | |
| 459 | /* |
| 460 | * Flags on the keepon member of the Curl_transfer_keeper |
| 461 | */ |
| 462 | |
| 463 | #define KEEP_NONE 0 |
| 464 | #define KEEP_RECV (1<<0) /* there is or may be data to read */ |
| 465 | #define KEEP_SEND (1<<1) /* there is or may be data to write */ |
| 466 | #define KEEP_RECV_HOLD (1<<2) /* when set, no reading should be done but there |
| 467 | might still be data to read */ |
| 468 | #define KEEP_SEND_HOLD (1<<3) /* when set, no writing should be done but there |
| 469 | might still be data to write */ |
| 470 | #define KEEP_RECV_PAUSE (1<<4) /* reading is paused */ |
| 471 | #define KEEP_SEND_PAUSE (1<<5) /* writing is paused */ |
| 472 | |
| 473 | #define KEEP_RECVBITS (KEEP_RECV | KEEP_RECV_HOLD | KEEP_RECV_PAUSE) |
| 474 | #define KEEP_SENDBITS (KEEP_SEND | KEEP_SEND_HOLD | KEEP_SEND_PAUSE) |
| 475 | |
| 476 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 477 | #ifdef CURLRES_ASYNCH |
| 478 | struct Curl_async { |
| 479 | char *hostname; |
| 480 | int port; |
| 481 | struct Curl_dns_entry *dns; |
| 482 | bool done; /* set TRUE when the lookup is complete */ |
| 483 | int status; /* if done is TRUE, this is the status from the callback */ |
| 484 | void *os_specific; /* 'struct thread_data' for Windows */ |
| 485 | }; |
| 486 | #endif |
| 487 | |
| 488 | #define FIRSTSOCKET 0 |
| 489 | #define SECONDARYSOCKET 1 |
| 490 | |
| 491 | /* These function pointer types are here only to allow easier typecasting |
| 492 | within the source when we need to cast between data pointers (such as NULL) |
| 493 | and function pointers. */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 494 | typedef CURLcode (*Curl_do_more_func)(struct connectdata *, int *); |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 495 | typedef CURLcode (*Curl_done_func)(struct connectdata *, CURLcode, bool); |
| 496 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 497 | enum expect100 { |
| 498 | EXP100_SEND_DATA, /* enough waiting, just send the body now */ |
| 499 | EXP100_AWAITING_CONTINUE, /* waiting for the 100 Continue header */ |
| 500 | EXP100_SENDING_REQUEST, /* still sending the request but will wait for |
| 501 | the 100 header once done with the request */ |
| 502 | EXP100_FAILED /* used on 417 Expectation Failed */ |
| 503 | }; |
| 504 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 505 | enum upgrade101 { |
| 506 | UPGR101_INIT, /* default state */ |
| 507 | UPGR101_REQUESTED, /* upgrade requested */ |
| 508 | UPGR101_RECEIVED, /* response received */ |
| 509 | UPGR101_WORKING /* talking upgraded protocol */ |
| 510 | }; |
| 511 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 512 | /* |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 513 | * Request specific data in the easy handle (Curl_easy). Previously, |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 514 | * these members were on the connectdata struct but since a conn struct may |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 515 | * now be shared between different Curl_easys, we store connection-specific |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 516 | * data here. This struct only keeps stuff that's interesting for *this* |
| 517 | * request, as it will be cleared between multiple ones |
| 518 | */ |
| 519 | struct SingleRequest { |
| 520 | curl_off_t size; /* -1 if unknown at this point */ |
| 521 | curl_off_t *bytecountp; /* return number of bytes read or NULL */ |
| 522 | |
| 523 | curl_off_t maxdownload; /* in bytes, the maximum amount of data to fetch, |
| 524 | -1 means unlimited */ |
| 525 | curl_off_t *writebytecountp; /* return number of bytes written or NULL */ |
| 526 | |
| 527 | curl_off_t bytecount; /* total number of bytes read */ |
| 528 | curl_off_t writebytecount; /* number of bytes written */ |
| 529 | |
| 530 | long headerbytecount; /* only count received headers */ |
| 531 | long deductheadercount; /* this amount of bytes doesn't count when we check |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 532 | if anything has been transferred at the end of a |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 533 | connection. We use this counter to make only a |
| 534 | 100 reply (without a following second response |
| 535 | code) result in a CURLE_GOT_NOTHING error code */ |
| 536 | |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 537 | struct curltime start; /* transfer started at this time */ |
| 538 | struct curltime now; /* current time */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 539 | bool header; /* incoming data has HTTP header */ |
| 540 | enum { |
| 541 | HEADER_NORMAL, /* no bad header at all */ |
| 542 | HEADER_PARTHEADER, /* part of the chunk is a bad header, the rest |
| 543 | is normal data */ |
| 544 | HEADER_ALLBAD /* all was believed to be header */ |
| 545 | } badheader; /* the header was deemed bad and will be |
| 546 | written as body */ |
| 547 | int headerline; /* counts header lines to better track the |
| 548 | first one */ |
| 549 | char *hbufp; /* points at *end* of header line */ |
| 550 | size_t hbuflen; |
| 551 | char *str; /* within buf */ |
| 552 | char *str_start; /* within buf */ |
| 553 | char *end_ptr; /* within buf */ |
| 554 | char *p; /* within headerbuff */ |
| 555 | bool content_range; /* set TRUE if Content-Range: was found */ |
| 556 | curl_off_t offset; /* possible resume offset read from the |
| 557 | Content-Range: header */ |
| 558 | int httpcode; /* error code from the 'HTTP/1.? XXX' or |
| 559 | 'RTSP/1.? XXX' line */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 560 | struct curltime start100; /* time stamp to wait for the 100 code from */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 561 | enum expect100 exp100; /* expect 100 continue state */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 562 | enum upgrade101 upgr101; /* 101 upgrade state */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 563 | |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 564 | struct contenc_writer_s *writer_stack; /* Content unencoding stack. */ |
| 565 | /* See sec 3.5, RFC2616. */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 566 | time_t timeofdoc; |
| 567 | long bodywrites; |
| 568 | |
| 569 | char *buf; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 570 | curl_socket_t maxfd; |
| 571 | |
| 572 | int keepon; |
| 573 | |
| 574 | bool upload_done; /* set to TRUE when doing chunked transfer-encoding upload |
| 575 | and we're uploading the last chunk */ |
| 576 | |
| 577 | bool ignorebody; /* we read a response-body but we ignore it! */ |
| 578 | bool ignorecl; /* This HTTP response has no body so we ignore the Content- |
| 579 | Length: header */ |
| 580 | |
| 581 | char *location; /* This points to an allocated version of the Location: |
| 582 | header data */ |
| 583 | char *newurl; /* Set to the new URL to use when a redirect or a retry is |
| 584 | wanted */ |
| 585 | |
| 586 | /* 'upload_present' is used to keep a byte counter of how much data there is |
| 587 | still left in the buffer, aimed for upload. */ |
| 588 | ssize_t upload_present; |
| 589 | |
| 590 | /* 'upload_fromhere' is used as a read-pointer when we uploaded parts of a |
| 591 | buffer, so the next read should read from where this pointer points to, |
| 592 | and the 'upload_present' contains the number of bytes available at this |
| 593 | position */ |
| 594 | char *upload_fromhere; |
| 595 | |
| 596 | bool chunk; /* if set, this is a chunked transfer-encoding */ |
| 597 | bool upload_chunky; /* set TRUE if we are doing chunked transfer-encoding |
| 598 | on upload */ |
| 599 | bool getheader; /* TRUE if header parsing is wanted */ |
| 600 | |
| 601 | bool forbidchunk; /* used only to explicitly forbid chunk-upload for |
| 602 | specific upload buffers. See readmoredata() in |
| 603 | http.c for details. */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 604 | |
| 605 | void *protop; /* Allocated protocol-specific data. Each protocol |
| 606 | handler makes sure this points to data it needs. */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 607 | }; |
| 608 | |
| 609 | /* |
| 610 | * Specific protocol handler. |
| 611 | */ |
| 612 | |
| 613 | struct Curl_handler { |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 614 | const char *scheme; /* URL scheme name. */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 615 | |
| 616 | /* Complement to setup_connection_internals(). */ |
| 617 | CURLcode (*setup_connection)(struct connectdata *); |
| 618 | |
| 619 | /* These two functions MUST be set to be protocol dependent */ |
| 620 | CURLcode (*do_it)(struct connectdata *, bool *done); |
| 621 | Curl_done_func done; |
| 622 | |
| 623 | /* If the curl_do() function is better made in two halves, this |
| 624 | * curl_do_more() function will be called afterwards, if set. For example |
| 625 | * for doing the FTP stuff after the PASV/PORT command. |
| 626 | */ |
| 627 | Curl_do_more_func do_more; |
| 628 | |
| 629 | /* This function *MAY* be set to a protocol-dependent function that is run |
| 630 | * after the connect() and everything is done, as a step in the connection. |
| 631 | * The 'done' pointer points to a bool that should be set to TRUE if the |
| 632 | * function completes before return. If it doesn't complete, the caller |
| 633 | * should call the curl_connecting() function until it is. |
| 634 | */ |
| 635 | CURLcode (*connect_it)(struct connectdata *, bool *done); |
| 636 | |
| 637 | /* See above. Currently only used for FTP. */ |
| 638 | CURLcode (*connecting)(struct connectdata *, bool *done); |
| 639 | CURLcode (*doing)(struct connectdata *, bool *done); |
| 640 | |
| 641 | /* Called from the multi interface during the PROTOCONNECT phase, and it |
| 642 | should then return a proper fd set */ |
| 643 | int (*proto_getsock)(struct connectdata *conn, |
| 644 | curl_socket_t *socks, |
| 645 | int numsocks); |
| 646 | |
| 647 | /* Called from the multi interface during the DOING phase, and it should |
| 648 | then return a proper fd set */ |
| 649 | int (*doing_getsock)(struct connectdata *conn, |
| 650 | curl_socket_t *socks, |
| 651 | int numsocks); |
| 652 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 653 | /* Called from the multi interface during the DO_MORE phase, and it should |
| 654 | then return a proper fd set */ |
| 655 | int (*domore_getsock)(struct connectdata *conn, |
| 656 | curl_socket_t *socks, |
| 657 | int numsocks); |
| 658 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 659 | /* Called from the multi interface during the DO_DONE, PERFORM and |
| 660 | WAITPERFORM phases, and it should then return a proper fd set. Not setting |
| 661 | this will make libcurl use the generic default one. */ |
| 662 | int (*perform_getsock)(const struct connectdata *conn, |
| 663 | curl_socket_t *socks, |
| 664 | int numsocks); |
| 665 | |
| 666 | /* This function *MAY* be set to a protocol-dependent function that is run |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 667 | * by the curl_disconnect(), as a step in the disconnection. If the handler |
| 668 | * is called because the connection has been considered dead, dead_connection |
| 669 | * is set to TRUE. |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 670 | */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 671 | CURLcode (*disconnect)(struct connectdata *, bool dead_connection); |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 672 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 673 | /* If used, this function gets called from transfer.c:readwrite_data() to |
| 674 | allow the protocol to do extra reads/writes */ |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 675 | CURLcode (*readwrite)(struct Curl_easy *data, struct connectdata *conn, |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 676 | ssize_t *nread, bool *readmore); |
| 677 | |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 678 | /* This function can perform various checks on the connection. See |
| 679 | CONNCHECK_* for more information about the checks that can be performed, |
| 680 | and CONNRESULT_* for the results that can be returned. */ |
| 681 | unsigned int (*connection_check)(struct connectdata *conn, |
| 682 | unsigned int checks_to_perform); |
| 683 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 684 | long defport; /* Default port. */ |
| 685 | unsigned int protocol; /* See CURLPROTO_* - this needs to be the single |
| 686 | specific protocol bit */ |
| 687 | unsigned int flags; /* Extra particular characteristics, see PROTOPT_* */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 688 | }; |
| 689 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 690 | #define PROTOPT_NONE 0 /* nothing extra */ |
| 691 | #define PROTOPT_SSL (1<<0) /* uses SSL */ |
| 692 | #define PROTOPT_DUAL (1<<1) /* this protocol uses two connections */ |
| 693 | #define PROTOPT_CLOSEACTION (1<<2) /* need action before socket close */ |
| 694 | /* some protocols will have to call the underlying functions without regard to |
| 695 | what exact state the socket signals. IE even if the socket says "readable", |
| 696 | the send function might need to be called while uploading, or vice versa. |
| 697 | */ |
| 698 | #define PROTOPT_DIRLOCK (1<<3) |
| 699 | #define PROTOPT_NONETWORK (1<<4) /* protocol doesn't use the network! */ |
| 700 | #define PROTOPT_NEEDSPWD (1<<5) /* needs a password, and if none is set it |
| 701 | gets a default */ |
| 702 | #define PROTOPT_NOURLQUERY (1<<6) /* protocol can't handle |
| 703 | url query strings (?foo=bar) ! */ |
| 704 | #define PROTOPT_CREDSPERREQUEST (1<<7) /* requires login credentials per |
| 705 | request instead of per connection */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 706 | #define PROTOPT_ALPN_NPN (1<<8) /* set ALPN and/or NPN for this */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 707 | #define PROTOPT_STREAM (1<<9) /* a protocol with individual logical streams */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 708 | #define PROTOPT_URLOPTIONS (1<<10) /* allow options part in the userinfo field |
| 709 | of the URL */ |
| 710 | #define PROTOPT_PROXY_AS_HTTP (1<<11) /* allow this non-HTTP scheme over a |
| 711 | HTTP proxy as HTTP proxies may know |
| 712 | this protocol and act as a gateway */ |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 713 | #define PROTOPT_WILDCARD (1<<12) /* protocol supports wildcard matching */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 714 | |
| 715 | #define CONNCHECK_NONE 0 /* No checks */ |
| 716 | #define CONNCHECK_ISDEAD (1<<0) /* Check if the connection is dead. */ |
| 717 | |
| 718 | #define CONNRESULT_NONE 0 /* No extra information. */ |
| 719 | #define CONNRESULT_DEAD (1<<0) /* The connection is dead. */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 720 | |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 721 | #ifdef USE_RECV_BEFORE_SEND_WORKAROUND |
| 722 | struct postponed_data { |
| 723 | char *buffer; /* Temporal store for received data during |
| 724 | sending, must be freed */ |
| 725 | size_t allocated_size; /* Size of temporal store */ |
| 726 | size_t recv_size; /* Size of received data during sending */ |
| 727 | size_t recv_processed; /* Size of processed part of postponed data */ |
| 728 | #ifdef DEBUGBUILD |
| 729 | curl_socket_t bindsock;/* Structure must be bound to specific socket, |
| 730 | used only for DEBUGASSERT */ |
| 731 | #endif /* DEBUGBUILD */ |
| 732 | }; |
| 733 | #endif /* USE_RECV_BEFORE_SEND_WORKAROUND */ |
| 734 | |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 735 | struct proxy_info { |
| 736 | struct hostname host; |
| 737 | long port; |
| 738 | curl_proxytype proxytype; /* what kind of proxy that is in use */ |
| 739 | char *user; /* proxy user name string, allocated */ |
| 740 | char *passwd; /* proxy password string, allocated */ |
| 741 | }; |
| 742 | |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 743 | #define CONNECT_BUFFER_SIZE 16384 |
| 744 | |
| 745 | /* struct for HTTP CONNECT state data */ |
| 746 | struct http_connect_state { |
| 747 | char connect_buffer[CONNECT_BUFFER_SIZE]; |
| 748 | int perline; /* count bytes per line */ |
| 749 | int keepon; |
| 750 | char *line_start; |
| 751 | char *ptr; /* where to store more data */ |
| 752 | curl_off_t cl; /* size of content to read and ignore */ |
| 753 | bool chunked_encoding; |
| 754 | enum { |
| 755 | TUNNEL_INIT, /* init/default/no tunnel state */ |
| 756 | TUNNEL_CONNECT, /* CONNECT has been sent off */ |
| 757 | TUNNEL_COMPLETE /* CONNECT response received completely */ |
| 758 | } tunnel_state; |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 759 | bool close_connection; |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 760 | }; |
| 761 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 762 | /* |
| 763 | * The connectdata struct contains all fields and variables that should be |
| 764 | * unique for an entire connection. |
| 765 | */ |
| 766 | struct connectdata { |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 767 | /* 'data' is the CURRENT Curl_easy using this connection -- take great |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 768 | caution that this might very well vary between different times this |
| 769 | connection is used! */ |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 770 | struct Curl_easy *data; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 771 | |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 772 | struct curl_llist_element bundle_node; /* conncache */ |
| 773 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 774 | /* chunk is for HTTP chunked encoding, but is in the general connectdata |
| 775 | struct only because we can do just about any protocol through a HTTP proxy |
| 776 | and a HTTP proxy may in fact respond using chunked encoding */ |
| 777 | struct Curl_chunker chunk; |
| 778 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 779 | curl_closesocket_callback fclosesocket; /* function closing the socket(s) */ |
| 780 | void *closesocket_client; |
| 781 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 782 | bool inuse; /* This is a marker for the connection cache logic. If this is |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 783 | TRUE this handle is being used by one or more easy handles |
| 784 | and can only used by any other easy handle without careful |
| 785 | consideration (== only for pipelining/multiplexing) and it |
| 786 | cannot be used by another multi handle! */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 787 | |
| 788 | /**** Fields set when inited and not modified again */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 789 | long connection_id; /* Contains a unique number to make it easier to |
| 790 | track the connections in the log output */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 791 | |
| 792 | /* 'dns_entry' is the particular host we use. This points to an entry in the |
| 793 | DNS cache and it will not get pruned while locked. It gets unlocked in |
| 794 | Curl_done(). This entry will be NULL if the connection is re-used as then |
| 795 | there is no name resolve done. */ |
| 796 | struct Curl_dns_entry *dns_entry; |
| 797 | |
| 798 | /* 'ip_addr' is the particular IP we connected to. It points to a struct |
| 799 | within the DNS cache, so this pointer is only valid as long as the DNS |
| 800 | cache entry remains locked. It gets unlocked in Curl_done() */ |
| 801 | Curl_addrinfo *ip_addr; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 802 | Curl_addrinfo *tempaddr[2]; /* for happy eyeballs */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 803 | |
| 804 | /* 'ip_addr_str' is the ip_addr data as a human readable string. |
| 805 | It remains available as long as the connection does, which is longer than |
| 806 | the ip_addr itself. */ |
| 807 | char ip_addr_str[MAX_IPADR_LEN]; |
| 808 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 809 | unsigned int scope_id; /* Scope id for IPv6 */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 810 | |
| 811 | int socktype; /* SOCK_STREAM or SOCK_DGRAM */ |
| 812 | |
| 813 | struct hostname host; |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 814 | char *secondaryhostname; /* secondary socket host name (ftp) */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 815 | struct hostname conn_to_host; /* the host to connect to. valid only if |
| 816 | bits.conn_to_host is set */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 817 | |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 818 | struct proxy_info socks_proxy; |
| 819 | struct proxy_info http_proxy; |
| 820 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 821 | long port; /* which port to use locally */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 822 | int remote_port; /* the remote port, not the proxy port! */ |
| 823 | int conn_to_port; /* the remote port to connect to. valid only if |
| 824 | bits.conn_to_port is set */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 825 | unsigned short secondary_port; /* secondary socket remote port to connect to |
| 826 | (ftp) */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 827 | |
| 828 | /* 'primary_ip' and 'primary_port' get filled with peer's numerical |
| 829 | ip address and port number whenever an outgoing connection is |
| 830 | *attempted* from the primary socket to a remote address. When more |
| 831 | than one address is tried for a connection these will hold data |
| 832 | for the last attempt. When the connection is actually established |
| 833 | these are updated with data which comes directly from the socket. */ |
| 834 | |
| 835 | char primary_ip[MAX_IPADR_LEN]; |
| 836 | long primary_port; |
| 837 | |
| 838 | /* 'local_ip' and 'local_port' get filled with local's numerical |
| 839 | ip address and port number whenever an outgoing connection is |
| 840 | **established** from the primary socket to a remote address. */ |
| 841 | |
| 842 | char local_ip[MAX_IPADR_LEN]; |
| 843 | long local_port; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 844 | |
| 845 | char *user; /* user name string, allocated */ |
| 846 | char *passwd; /* password string, allocated */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 847 | char *options; /* options string, allocated */ |
| 848 | |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 849 | char *oauth_bearer; /* bearer token for OAuth 2.0, allocated */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 850 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 851 | int httpversion; /* the HTTP version*10 reported by the server */ |
| 852 | int rtspversion; /* the RTSP version*10 reported by the server */ |
| 853 | |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 854 | struct curltime now; /* "current" time */ |
| 855 | struct curltime created; /* creation time */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 856 | curl_socket_t sock[2]; /* two sockets, the second is used for the data |
| 857 | transfer when doing FTP */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 858 | curl_socket_t tempsock[2]; /* temporary sockets for happy eyeballs */ |
| 859 | bool sock_accepted[2]; /* TRUE if the socket on this index was created with |
| 860 | accept() */ |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 861 | Curl_recv *recv[2]; |
| 862 | Curl_send *send[2]; |
| 863 | |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 864 | #ifdef USE_RECV_BEFORE_SEND_WORKAROUND |
| 865 | struct postponed_data postponed[2]; /* two buffers for two sockets */ |
| 866 | #endif /* USE_RECV_BEFORE_SEND_WORKAROUND */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 867 | struct ssl_connect_data ssl[2]; /* this is for ssl-stuff */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 868 | struct ssl_connect_data proxy_ssl[2]; /* this is for proxy ssl-stuff */ |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 869 | #ifdef USE_SSL |
| 870 | void *ssl_extra; /* separately allocated backend-specific data */ |
| 871 | #endif |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 872 | struct ssl_primary_config ssl_config; |
| 873 | struct ssl_primary_config proxy_ssl_config; |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 874 | bool tls_upgraded; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 875 | |
| 876 | struct ConnectBits bits; /* various state-flags for this connection */ |
| 877 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 878 | /* connecttime: when connect() is called on the current IP address. Used to |
| 879 | be able to track when to move on to try next IP - but only when the multi |
| 880 | interface is used. */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 881 | struct curltime connecttime; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 882 | /* The two fields below get set in Curl_connecthost */ |
| 883 | int num_addr; /* number of addresses to try to connect to */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 884 | time_t timeoutms_per_addr; /* how long time in milliseconds to spend on |
| 885 | trying to connect to each IP address */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 886 | |
| 887 | const struct Curl_handler *handler; /* Connection's protocol handler */ |
| 888 | const struct Curl_handler *given; /* The protocol first given */ |
| 889 | |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 890 | long ip_version; /* copied from the Curl_easy at creation time */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 891 | |
| 892 | /**** curl_get() phase fields */ |
| 893 | |
| 894 | curl_socket_t sockfd; /* socket to read from or CURL_SOCKET_BAD */ |
| 895 | curl_socket_t writesockfd; /* socket to write to, it may very |
| 896 | well be the same we read from. |
| 897 | CURL_SOCKET_BAD disables */ |
| 898 | |
Elliott Hughes | 1ef06ba | 2018-05-30 15:43:58 -0700 | [diff] [blame] | 899 | /** Dynamically allocated strings, MUST be freed before this **/ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 900 | /** struct is killed. **/ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 901 | struct dynamically_allocated_data { |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 902 | char *proxyuserpwd; |
| 903 | char *uagent; |
| 904 | char *accept_encoding; |
| 905 | char *userpwd; |
| 906 | char *rangeline; |
| 907 | char *ref; |
| 908 | char *host; |
| 909 | char *cookiehost; |
| 910 | char *rtsp_transport; |
| 911 | char *te; /* TE: request header */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 912 | } allocptr; |
| 913 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 914 | #ifdef HAVE_GSSAPI |
| 915 | int sec_complete; /* if Kerberos is enabled for this connection */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 916 | enum protection_level command_prot; |
| 917 | enum protection_level data_prot; |
| 918 | enum protection_level request_data_prot; |
| 919 | size_t buffer_size; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 920 | struct krb5buffer in_buffer; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 921 | void *app_data; |
| 922 | const struct Curl_sec_client_mech *mech; |
| 923 | struct sockaddr_in local_addr; |
| 924 | #endif |
| 925 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 926 | #if defined(USE_KERBEROS5) /* Consider moving some of the above GSS-API */ |
| 927 | struct kerberos5data krb5; /* variables into the structure definition, */ |
| 928 | #endif /* however, some of them are ftp specific. */ |
| 929 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 930 | /* the two following *_inuse fields are only flags, not counters in any way. |
| 931 | If TRUE it means the channel is in use, and if FALSE it means the channel |
| 932 | is up for grabs by one. */ |
| 933 | |
| 934 | bool readchannel_inuse; /* whether the read channel is in use by an easy |
| 935 | handle */ |
| 936 | bool writechannel_inuse; /* whether the write channel is in use by an easy |
| 937 | handle */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 938 | struct curl_llist send_pipe; /* List of handles waiting to send on this |
| 939 | pipeline */ |
| 940 | struct curl_llist recv_pipe; /* List of handles waiting to read their |
| 941 | responses on this pipeline */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 942 | char *master_buffer; /* The master buffer allocated on-demand; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 943 | used for pipelining. */ |
| 944 | size_t read_pos; /* Current read position in the master buffer */ |
| 945 | size_t buf_len; /* Length of the buffer?? */ |
| 946 | |
| 947 | |
| 948 | curl_seek_callback seek_func; /* function that seeks the input */ |
| 949 | void *seek_client; /* pointer to pass to the seek() above */ |
| 950 | |
| 951 | /*************** Request - specific items ************/ |
| 952 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 953 | #if defined(USE_NTLM) |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 954 | struct ntlmdata ntlm; /* NTLM differs from other authentication schemes |
| 955 | because it authenticates connections, not |
| 956 | single requests! */ |
| 957 | struct ntlmdata proxyntlm; /* NTLM data for proxy */ |
| 958 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 959 | #if defined(NTLM_WB_ENABLED) |
| 960 | /* used for communication with Samba's winbind daemon helper ntlm_auth */ |
| 961 | curl_socket_t ntlm_auth_hlpr_socket; |
| 962 | pid_t ntlm_auth_hlpr_pid; |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 963 | char *challenge_header; |
| 964 | char *response_header; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 965 | #endif |
| 966 | #endif |
| 967 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 968 | char syserr_buf [256]; /* buffer for Curl_strerror() */ |
| 969 | |
| 970 | #ifdef CURLRES_ASYNCH |
| 971 | /* data used for the asynch name resolve callback */ |
| 972 | struct Curl_async async; |
| 973 | #endif |
| 974 | |
| 975 | /* These three are used for chunked-encoding trailer support */ |
| 976 | char *trailer; /* allocated buffer to store trailer in */ |
| 977 | int trlMax; /* allocated buffer size */ |
| 978 | int trlPos; /* index of where to store data */ |
| 979 | |
| 980 | union { |
| 981 | struct ftp_conn ftpc; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 982 | struct http_conn httpc; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 983 | struct ssh_conn sshc; |
| 984 | struct tftp_state_data *tftpc; |
| 985 | struct imap_conn imapc; |
| 986 | struct pop3_conn pop3c; |
| 987 | struct smtp_conn smtpc; |
| 988 | struct rtsp_conn rtspc; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 989 | struct smb_conn smbc; |
| 990 | void *generic; /* RTMP and LDAP use this */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 991 | } proto; |
| 992 | |
| 993 | int cselect_bits; /* bitmask of socket events */ |
| 994 | int waitfor; /* current READ/WRITE bits to wait for */ |
| 995 | |
| 996 | #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) |
| 997 | int socks5_gssapi_enctype; |
| 998 | #endif |
| 999 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1000 | /* When this connection is created, store the conditions for the local end |
| 1001 | bind. This is stored before the actual bind and before any connection is |
| 1002 | made and will serve the purpose of being used for comparison reasons so |
| 1003 | that subsequent bound-requested connections aren't accidentally re-using |
| 1004 | wrong connections. */ |
| 1005 | char *localdev; |
| 1006 | unsigned short localport; |
| 1007 | int localportrange; |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1008 | struct http_connect_state *connect_state; /* for HTTP CONNECT */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1009 | struct connectbundle *bundle; /* The bundle we are member of */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1010 | int negnpn; /* APLN or NPN TLS negotiated protocol, CURL_HTTP_VERSION* */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1011 | |
| 1012 | #ifdef USE_UNIX_SOCKETS |
| 1013 | char *unix_domain_socket; |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1014 | bool abstract_unix_socket; |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1015 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1016 | }; |
| 1017 | |
| 1018 | /* The end of connectdata. */ |
| 1019 | |
| 1020 | /* |
| 1021 | * Struct to keep statistical and informational data. |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1022 | * All variables in this struct must be initialized/reset in Curl_initinfo(). |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1023 | */ |
| 1024 | struct PureInfo { |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1025 | int httpcode; /* Recent HTTP, FTP, RTSP or SMTP response code */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1026 | int httpproxycode; /* response code from proxy when received separate */ |
| 1027 | int httpversion; /* the http version number X.Y = X*10+Y */ |
Elliott Hughes | cac3980 | 2018-04-27 16:19:43 -0700 | [diff] [blame] | 1028 | time_t filetime; /* If requested, this is might get set. Set to -1 if the |
| 1029 | time was unretrievable. */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1030 | bool timecond; /* set to TRUE if the time condition didn't match, which |
| 1031 | thus made the document NOT get fetched */ |
| 1032 | long header_size; /* size of read header(s) in bytes */ |
| 1033 | long request_size; /* the amount of bytes sent in the request(s) */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1034 | unsigned long proxyauthavail; /* what proxy auth types were announced */ |
| 1035 | unsigned long httpauthavail; /* what host auth types were announced */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1036 | long numconnects; /* how many new connection did libcurl created */ |
| 1037 | char *contenttype; /* the content type of the object */ |
| 1038 | char *wouldredirect; /* URL this would've been redirected to if asked to */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1039 | |
| 1040 | /* PureInfo members 'conn_primary_ip', 'conn_primary_port', 'conn_local_ip' |
| 1041 | and, 'conn_local_port' are copied over from the connectdata struct in |
| 1042 | order to allow curl_easy_getinfo() to return this information even when |
| 1043 | the session handle is no longer associated with a connection, and also |
| 1044 | allow curl_easy_reset() to clear this information from the session handle |
| 1045 | without disturbing information which is still alive, and that might be |
| 1046 | reused, in the connection cache. */ |
| 1047 | |
| 1048 | char conn_primary_ip[MAX_IPADR_LEN]; |
| 1049 | long conn_primary_port; |
| 1050 | |
| 1051 | char conn_local_ip[MAX_IPADR_LEN]; |
| 1052 | long conn_local_port; |
| 1053 | |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1054 | const char *conn_scheme; |
| 1055 | unsigned int conn_protocol; |
| 1056 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1057 | struct curl_certinfo certs; /* info about the certs, only populated in |
| 1058 | OpenSSL builds. Asked for with |
| 1059 | CURLOPT_CERTINFO / CURLINFO_CERTINFO */ |
| 1060 | }; |
| 1061 | |
| 1062 | |
| 1063 | struct Progress { |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1064 | time_t lastshow; /* time() of the last displayed progress meter or NULL to |
| 1065 | force redraw at next call */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1066 | curl_off_t size_dl; /* total expected size */ |
| 1067 | curl_off_t size_ul; /* total expected size */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1068 | curl_off_t downloaded; /* transferred so far */ |
| 1069 | curl_off_t uploaded; /* transferred so far */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1070 | |
| 1071 | curl_off_t current_speed; /* uses the currently fastest transfer */ |
| 1072 | |
| 1073 | bool callback; /* set when progress callback is used */ |
| 1074 | int width; /* screen width at download start */ |
| 1075 | int flags; /* see progress.h */ |
| 1076 | |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1077 | time_t timespent; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1078 | |
| 1079 | curl_off_t dlspeed; |
| 1080 | curl_off_t ulspeed; |
| 1081 | |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1082 | time_t t_nslookup; |
| 1083 | time_t t_connect; |
| 1084 | time_t t_appconnect; |
| 1085 | time_t t_pretransfer; |
| 1086 | time_t t_starttransfer; |
| 1087 | time_t t_redirect; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1088 | |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1089 | struct curltime start; |
| 1090 | struct curltime t_startsingle; |
| 1091 | struct curltime t_startop; |
| 1092 | struct curltime t_acceptdata; |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1093 | |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 1094 | bool is_t_startransfer_set; |
| 1095 | |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1096 | /* upload speed limit */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1097 | struct curltime ul_limit_start; |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1098 | curl_off_t ul_limit_size; |
| 1099 | /* download speed limit */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1100 | struct curltime dl_limit_start; |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1101 | curl_off_t dl_limit_size; |
| 1102 | |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 1103 | #define CURR_TIME (5 + 1) /* 6 entries for 5 seconds */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1104 | |
| 1105 | curl_off_t speeder[ CURR_TIME ]; |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1106 | struct curltime speeder_time[ CURR_TIME ]; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1107 | int speeder_c; |
| 1108 | }; |
| 1109 | |
| 1110 | typedef enum { |
| 1111 | HTTPREQ_NONE, /* first in list */ |
| 1112 | HTTPREQ_GET, |
| 1113 | HTTPREQ_POST, |
| 1114 | HTTPREQ_POST_FORM, /* we make a difference internally */ |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 1115 | HTTPREQ_POST_MIME, /* we make a difference internally */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1116 | HTTPREQ_PUT, |
| 1117 | HTTPREQ_HEAD, |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1118 | HTTPREQ_OPTIONS, |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1119 | HTTPREQ_CUSTOM, |
| 1120 | HTTPREQ_LAST /* last in list */ |
| 1121 | } Curl_HttpReq; |
| 1122 | |
| 1123 | typedef enum { |
| 1124 | RTSPREQ_NONE, /* first in list */ |
| 1125 | RTSPREQ_OPTIONS, |
| 1126 | RTSPREQ_DESCRIBE, |
| 1127 | RTSPREQ_ANNOUNCE, |
| 1128 | RTSPREQ_SETUP, |
| 1129 | RTSPREQ_PLAY, |
| 1130 | RTSPREQ_PAUSE, |
| 1131 | RTSPREQ_TEARDOWN, |
| 1132 | RTSPREQ_GET_PARAMETER, |
| 1133 | RTSPREQ_SET_PARAMETER, |
| 1134 | RTSPREQ_RECORD, |
| 1135 | RTSPREQ_RECEIVE, |
| 1136 | RTSPREQ_LAST /* last in list */ |
| 1137 | } Curl_RtspReq; |
| 1138 | |
| 1139 | /* |
| 1140 | * Values that are generated, temporary or calculated internally for a |
| 1141 | * "session handle" must be defined within the 'struct UrlState'. This struct |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 1142 | * will be used within the Curl_easy struct. When the 'Curl_easy' |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1143 | * struct is cloned, this data MUST NOT be copied. |
| 1144 | * |
| 1145 | * Remember that any "state" information goes globally for the curl handle. |
| 1146 | * Session-data MUST be put in the connectdata struct and here. */ |
| 1147 | #define MAX_CURL_USER_LENGTH 256 |
| 1148 | #define MAX_CURL_PASSWORD_LENGTH 256 |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1149 | |
| 1150 | struct auth { |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1151 | unsigned long want; /* Bitmask set to the authentication methods wanted by |
| 1152 | app (with CURLOPT_HTTPAUTH or CURLOPT_PROXYAUTH). */ |
| 1153 | unsigned long picked; |
| 1154 | unsigned long avail; /* Bitmask for what the server reports to support for |
| 1155 | this resource */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1156 | bool done; /* TRUE when the auth phase is done and ready to do the *actual* |
| 1157 | request */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1158 | bool multipass; /* TRUE if this is not yet authenticated but within the |
| 1159 | auth multipass negotiation */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1160 | bool iestyle; /* TRUE if digest should be done IE-style or FALSE if it should |
| 1161 | be RFC compliant */ |
| 1162 | }; |
| 1163 | |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1164 | struct Curl_http2_dep { |
| 1165 | struct Curl_http2_dep *next; |
| 1166 | struct Curl_easy *data; |
| 1167 | }; |
| 1168 | |
| 1169 | /* |
Elliott Hughes | cac3980 | 2018-04-27 16:19:43 -0700 | [diff] [blame] | 1170 | * This struct is for holding data that was attempted to get sent to the user's |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1171 | * callback but is held due to pausing. One instance per type (BOTH, HEADER, |
| 1172 | * BODY). |
| 1173 | */ |
| 1174 | struct tempbuf { |
| 1175 | char *buf; /* allocated buffer to keep data in when a write callback |
| 1176 | returns to make the connection paused */ |
| 1177 | size_t len; /* size of the 'tempwrite' allocated buffer */ |
| 1178 | int type; /* type of the 'tempwrite' buffer as a bitmask that is used with |
| 1179 | Curl_client_write() */ |
| 1180 | }; |
| 1181 | |
| 1182 | /* Timers */ |
| 1183 | typedef enum { |
| 1184 | EXPIRE_100_TIMEOUT, |
| 1185 | EXPIRE_ASYNC_NAME, |
| 1186 | EXPIRE_CONNECTTIMEOUT, |
| 1187 | EXPIRE_DNS_PER_NAME, |
| 1188 | EXPIRE_HAPPY_EYEBALLS, |
| 1189 | EXPIRE_MULTI_PENDING, |
| 1190 | EXPIRE_RUN_NOW, |
| 1191 | EXPIRE_SPEEDCHECK, |
| 1192 | EXPIRE_TIMEOUT, |
| 1193 | EXPIRE_TOOFAST, |
| 1194 | EXPIRE_LAST /* not an actual timer, used as a marker only */ |
| 1195 | } expire_id; |
| 1196 | |
| 1197 | /* |
| 1198 | * One instance for each timeout an easy handle can set. |
| 1199 | */ |
| 1200 | struct time_node { |
| 1201 | struct curl_llist_element list; |
| 1202 | struct curltime time; |
| 1203 | expire_id eid; |
| 1204 | }; |
| 1205 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1206 | struct UrlState { |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1207 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1208 | /* Points to the connection cache */ |
| 1209 | struct conncache *conn_cache; |
| 1210 | |
| 1211 | /* when curl_easy_perform() is called, the multi handle is "owned" by |
| 1212 | the easy handle so curl_easy_cleanup() on such an easy handle will |
| 1213 | also close the multi handle! */ |
| 1214 | bool multi_owned_by_easy; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1215 | |
| 1216 | /* buffers to store authentication data in, as parsed from input options */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1217 | struct curltime keeps_speed; /* for the progress meter really */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1218 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1219 | struct connectdata *lastconnect; /* The last connection, NULL if undefined */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1220 | |
| 1221 | char *headerbuff; /* allocated buffer to store headers in */ |
| 1222 | size_t headersize; /* size of the allocation */ |
| 1223 | |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1224 | char *buffer; /* download buffer */ |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 1225 | char uploadbuffer[UPLOAD_BUFSIZE + 1]; /* upload buffer */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1226 | curl_off_t current_speed; /* the ProgressShow() function sets this, |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1227 | bytes / second */ |
| 1228 | bool this_is_a_follow; /* this is a followed Location: request */ |
Elliott Hughes | 1ef06ba | 2018-05-30 15:43:58 -0700 | [diff] [blame] | 1229 | bool refused_stream; /* this was refused, try again */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1230 | char *first_host; /* host name of the first (not followed) request. |
| 1231 | if set, this should be the host name that we will |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1232 | sent authorization to, no else. Used to make Location: |
| 1233 | following not keep sending user+password... This is |
| 1234 | strdup() data. |
| 1235 | */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1236 | int first_remote_port; /* remote port of the first (not followed) request */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1237 | struct curl_ssl_session *session; /* array of 'max_ssl_sessions' size */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1238 | long sessionage; /* number of the most recent session */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1239 | unsigned int tempcount; /* number of entries in use in tempwrite, 0 - 3 */ |
| 1240 | struct tempbuf tempwrite[3]; /* BOTH, HEADER, BODY */ |
| 1241 | char *scratch; /* huge buffer[set.buffer_size*2] for upload CRLF replacing */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1242 | bool errorbuf; /* Set to TRUE if the error buffer is already filled in. |
| 1243 | This must be set to FALSE every time _easy_perform() is |
| 1244 | called. */ |
| 1245 | int os_errno; /* filled in with errno whenever an error occurs */ |
| 1246 | #ifdef HAVE_SIGNAL |
| 1247 | /* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */ |
| 1248 | void (*prev_signal)(int sig); |
| 1249 | #endif |
| 1250 | bool allow_port; /* Is set.use_port allowed to take effect or not. This |
| 1251 | is always set TRUE when curl_easy_perform() is called. */ |
| 1252 | struct digestdata digest; /* state data for host Digest auth */ |
| 1253 | struct digestdata proxydigest; /* state data for proxy Digest auth */ |
| 1254 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1255 | #ifdef USE_SPNEGO |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1256 | struct negotiatedata negotiate; /* state data for host Negotiate auth */ |
| 1257 | struct negotiatedata proxyneg; /* state data for proxy Negotiate auth */ |
| 1258 | #endif |
| 1259 | |
| 1260 | struct auth authhost; /* auth details for host */ |
| 1261 | struct auth authproxy; /* auth details for proxy */ |
| 1262 | |
| 1263 | bool authproblem; /* TRUE if there's some problem authenticating */ |
| 1264 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1265 | void *resolver; /* resolver state, if it is used in the URL state - |
| 1266 | ares_channel f.e. */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1267 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1268 | #if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H) |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 1269 | /* void instead of ENGINE to avoid bleeding OpenSSL into this header */ |
| 1270 | void *engine; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1271 | #endif /* USE_OPENSSL */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1272 | struct curltime expiretime; /* set this with Curl_expire() only */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1273 | struct Curl_tree timenode; /* for the splay stuff */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1274 | struct curl_llist timeoutlist; /* list of pending timeouts */ |
| 1275 | struct time_node expires[EXPIRE_LAST]; /* nodes for each expire type */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1276 | |
| 1277 | /* a place to store the most recently set FTP entrypath */ |
| 1278 | char *most_recent_ftp_entrypath; |
| 1279 | |
| 1280 | /* set after initial USER failure, to prevent an authentication loop */ |
| 1281 | bool ftp_trying_alternative; |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 1282 | bool wildcardmatch; /* enable wildcard matching */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1283 | int httpversion; /* the lowest HTTP version*10 reported by any server |
| 1284 | involved in this request */ |
| 1285 | bool expect100header; /* TRUE if we added Expect: 100-continue */ |
| 1286 | |
| 1287 | bool pipe_broke; /* TRUE if the connection we were pipelined on broke |
| 1288 | and we need to restart from the beginning */ |
| 1289 | |
| 1290 | #if !defined(WIN32) && !defined(MSDOS) && !defined(__EMX__) && \ |
| 1291 | !defined(__SYMBIAN32__) |
| 1292 | /* do FTP line-end conversions on most platforms */ |
| 1293 | #define CURL_DO_LINEEND_CONV |
| 1294 | /* for FTP downloads: track CRLF sequences that span blocks */ |
| 1295 | bool prev_block_had_trailing_cr; |
| 1296 | /* for FTP downloads: how many CRLFs did we converted to LFs? */ |
| 1297 | curl_off_t crlf_conversions; |
| 1298 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1299 | char *pathbuffer;/* allocated buffer to store the URL's path part in */ |
| 1300 | char *path; /* path to use, points to somewhere within the pathbuffer |
| 1301 | area */ |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 1302 | bool slash_removed; /* set TRUE if the 'path' points to a path where the |
| 1303 | initial URL slash separator has been taken off */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1304 | bool use_range; |
| 1305 | bool rangestringalloc; /* the range string is malloc()'ed */ |
| 1306 | |
| 1307 | char *range; /* range, if used. See README for detailed specification on |
| 1308 | this syntax. */ |
| 1309 | curl_off_t resume_from; /* continue [ftp] transfer from here */ |
| 1310 | |
| 1311 | /* This RTSP state information survives requests and connections */ |
| 1312 | long rtsp_next_client_CSeq; /* the session's next client CSeq */ |
| 1313 | long rtsp_next_server_CSeq; /* the session's next server CSeq */ |
| 1314 | long rtsp_CSeq_recv; /* most recent CSeq received */ |
| 1315 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1316 | curl_off_t infilesize; /* size of file to upload, -1 means unknown. |
| 1317 | Copied from set.filesize at start of operation */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1318 | |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1319 | size_t drain; /* Increased when this stream has data to read, even if its |
| 1320 | socket is not necessarily is readable. Decreased when |
| 1321 | checked. */ |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 1322 | bool done; /* set to FALSE when Curl_init_do() is called and set to TRUE |
| 1323 | when multi_done() is called, to prevent multi_done() to get |
| 1324 | invoked twice when the multi interface is used. */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1325 | |
| 1326 | curl_read_callback fread_func; /* read callback/function */ |
| 1327 | void *in; /* CURLOPT_READDATA */ |
| 1328 | |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 1329 | struct Curl_easy *stream_depends_on; |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1330 | bool stream_depends_e; /* set or don't set the Exclusive bit */ |
| 1331 | int stream_weight; |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 1332 | #ifdef CURLDEBUG |
| 1333 | bool conncache_lock; |
| 1334 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1335 | }; |
| 1336 | |
| 1337 | |
| 1338 | /* |
| 1339 | * This 'DynamicStatic' struct defines dynamic states that actually change |
| 1340 | * values in the 'UserDefined' area, which MUST be taken into consideration |
| 1341 | * if the UserDefined struct is cloned or similar. You can probably just |
| 1342 | * copy these, but each one indicate a special action on other data. |
| 1343 | */ |
| 1344 | |
| 1345 | struct DynamicStatic { |
| 1346 | char *url; /* work URL, copied from UserDefined */ |
| 1347 | bool url_alloc; /* URL string is malloc()'ed */ |
| 1348 | char *referer; /* referer string */ |
| 1349 | bool referer_alloc; /* referer sting is malloc()ed */ |
| 1350 | struct curl_slist *cookielist; /* list of cookie files set by |
| 1351 | curl_easy_setopt(COOKIEFILE) calls */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1352 | struct curl_slist *resolve; /* set to point to the set.resolve list when |
| 1353 | this should be dealt with in pretransfer */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1354 | }; |
| 1355 | |
| 1356 | /* |
| 1357 | * This 'UserDefined' struct must only contain data that is set once to go |
| 1358 | * for many (perhaps) independent connections. Values that are generated or |
| 1359 | * calculated internally for the "session handle" MUST be defined within the |
| 1360 | * 'struct UrlState' instead. The only exceptions MUST note the changes in |
| 1361 | * the 'DynamicStatic' struct. |
| 1362 | * Character pointer fields point to dynamic storage, unless otherwise stated. |
| 1363 | */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1364 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1365 | struct Curl_multi; /* declared and used only in multi.c */ |
| 1366 | |
| 1367 | enum dupstring { |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1368 | STRING_CERT_ORIG, /* client certificate file name */ |
| 1369 | STRING_CERT_PROXY, /* client certificate file name */ |
| 1370 | STRING_CERT_TYPE_ORIG, /* format for certificate (default: PEM)*/ |
| 1371 | STRING_CERT_TYPE_PROXY, /* format for certificate (default: PEM)*/ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1372 | STRING_COOKIE, /* HTTP cookie string to send */ |
| 1373 | STRING_COOKIEJAR, /* dump all cookies to this file */ |
| 1374 | STRING_CUSTOMREQUEST, /* HTTP/FTP/RTSP request/method to use */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1375 | STRING_DEFAULT_PROTOCOL, /* Protocol to use when the URL doesn't specify */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1376 | STRING_DEVICE, /* local network interface/address to use */ |
| 1377 | STRING_ENCODING, /* Accept-Encoding string */ |
| 1378 | STRING_FTP_ACCOUNT, /* ftp account data */ |
| 1379 | STRING_FTP_ALTERNATIVE_TO_USER, /* command to send if USER/PASS fails */ |
| 1380 | STRING_FTPPORT, /* port to send with the FTP PORT command */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1381 | STRING_KEY_ORIG, /* private key file name */ |
| 1382 | STRING_KEY_PROXY, /* private key file name */ |
| 1383 | STRING_KEY_PASSWD_ORIG, /* plain text private key password */ |
| 1384 | STRING_KEY_PASSWD_PROXY, /* plain text private key password */ |
| 1385 | STRING_KEY_TYPE_ORIG, /* format for private key (default: PEM) */ |
| 1386 | STRING_KEY_TYPE_PROXY, /* format for private key (default: PEM) */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1387 | STRING_KRB_LEVEL, /* krb security level */ |
| 1388 | STRING_NETRC_FILE, /* if not NULL, use this instead of trying to find |
| 1389 | $HOME/.netrc */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1390 | STRING_PROXY, /* proxy to use */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1391 | STRING_PRE_PROXY, /* pre socks proxy to use */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1392 | STRING_SET_RANGE, /* range, if used */ |
| 1393 | STRING_SET_REFERER, /* custom string for the HTTP referer field */ |
| 1394 | STRING_SET_URL, /* what original URL to work on */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1395 | STRING_SSL_CAPATH_ORIG, /* CA directory name (doesn't work on windows) */ |
| 1396 | STRING_SSL_CAPATH_PROXY, /* CA directory name (doesn't work on windows) */ |
| 1397 | STRING_SSL_CAFILE_ORIG, /* certificate file to verify peer against */ |
| 1398 | STRING_SSL_CAFILE_PROXY, /* certificate file to verify peer against */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1399 | STRING_SSL_PINNEDPUBLICKEY_ORIG, /* public key file to verify peer against */ |
| 1400 | STRING_SSL_PINNEDPUBLICKEY_PROXY, /* public key file to verify proxy */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1401 | STRING_SSL_CIPHER_LIST_ORIG, /* list of ciphers to use */ |
| 1402 | STRING_SSL_CIPHER_LIST_PROXY, /* list of ciphers to use */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1403 | STRING_SSL_EGDSOCKET, /* path to file containing the EGD daemon socket */ |
| 1404 | STRING_SSL_RANDOM_FILE, /* path to file containing "random" data */ |
| 1405 | STRING_USERAGENT, /* User-Agent string */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1406 | STRING_SSL_CRLFILE_ORIG, /* crl file to check certificate */ |
| 1407 | STRING_SSL_CRLFILE_PROXY, /* crl file to check certificate */ |
| 1408 | STRING_SSL_ISSUERCERT_ORIG, /* issuer cert file to check certificate */ |
| 1409 | STRING_SSL_ISSUERCERT_PROXY, /* issuer cert file to check certificate */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1410 | STRING_USERNAME, /* <username>, if used */ |
| 1411 | STRING_PASSWORD, /* <password>, if used */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1412 | STRING_OPTIONS, /* <options>, if used */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1413 | STRING_PROXYUSERNAME, /* Proxy <username>, if used */ |
| 1414 | STRING_PROXYPASSWORD, /* Proxy <password>, if used */ |
| 1415 | STRING_NOPROXY, /* List of hosts which should not use the proxy, if |
| 1416 | used */ |
| 1417 | STRING_RTSP_SESSION_ID, /* Session ID to use */ |
| 1418 | STRING_RTSP_STREAM_URI, /* Stream URI for this request */ |
| 1419 | STRING_RTSP_TRANSPORT, /* Transport for this session */ |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 1420 | #if defined(USE_LIBSSH2) || defined(USE_LIBSSH) |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1421 | STRING_SSH_PRIVATE_KEY, /* path to the private key file for auth */ |
| 1422 | STRING_SSH_PUBLIC_KEY, /* path to the public key file for auth */ |
| 1423 | STRING_SSH_HOST_PUBLIC_KEY_MD5, /* md5 of host public key in ascii hex */ |
| 1424 | STRING_SSH_KNOWNHOSTS, /* file name of knownhosts file */ |
| 1425 | #endif |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1426 | STRING_PROXY_SERVICE_NAME, /* Proxy service name */ |
| 1427 | STRING_SERVICE_NAME, /* Service name */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1428 | STRING_MAIL_FROM, |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1429 | STRING_MAIL_AUTH, |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1430 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1431 | #ifdef USE_TLS_SRP |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1432 | STRING_TLSAUTH_USERNAME_ORIG, /* TLS auth <username> */ |
| 1433 | STRING_TLSAUTH_USERNAME_PROXY, /* TLS auth <username> */ |
| 1434 | STRING_TLSAUTH_PASSWORD_ORIG, /* TLS auth <password> */ |
| 1435 | STRING_TLSAUTH_PASSWORD_PROXY, /* TLS auth <password> */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1436 | #endif |
| 1437 | STRING_BEARER, /* <bearer>, if used */ |
| 1438 | #ifdef USE_UNIX_SOCKETS |
| 1439 | STRING_UNIX_SOCKET_PATH, /* path to Unix socket, if used */ |
| 1440 | #endif |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1441 | STRING_TARGET, /* CURLOPT_REQUEST_TARGET */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1442 | /* -- end of zero-terminated strings -- */ |
| 1443 | |
| 1444 | STRING_LASTZEROTERMINATED, |
| 1445 | |
| 1446 | /* -- below this are pointers to binary data that cannot be strdup'ed. |
| 1447 | Each such pointer must be added manually to Curl_dupset() --- */ |
| 1448 | |
| 1449 | STRING_COPYPOSTFIELDS, /* if POST, set the fields' values here */ |
| 1450 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1451 | STRING_LAST /* not used, just an end-of-list marker */ |
| 1452 | }; |
| 1453 | |
| 1454 | struct UserDefined { |
| 1455 | FILE *err; /* the stderr user data goes here */ |
| 1456 | void *debugdata; /* the data that will be passed to fdebug */ |
| 1457 | char *errorbuffer; /* (Static) store failure messages in here */ |
| 1458 | long proxyport; /* If non-zero, use this port number by default. If the |
| 1459 | proxy string features a ":[port]" that one will override |
| 1460 | this. */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1461 | void *out; /* CURLOPT_WRITEDATA */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1462 | void *in_set; /* CURLOPT_READDATA */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1463 | void *writeheader; /* write the header to this if non-NULL */ |
| 1464 | void *rtp_out; /* write RTP to this if non-NULL */ |
| 1465 | long use_port; /* which port to use (when not using default) */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1466 | unsigned long httpauth; /* kind of HTTP authentication to use (bitmask) */ |
| 1467 | unsigned long proxyauth; /* kind of proxy authentication to use (bitmask) */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1468 | unsigned long socks5auth;/* kind of SOCKS5 authentication to use (bitmask) */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1469 | long followlocation; /* as in HTTP Location: */ |
| 1470 | long maxredirs; /* maximum no. of http(s) redirects to follow, set to -1 |
| 1471 | for infinity */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1472 | |
| 1473 | int keep_post; /* keep POSTs as POSTs after a 30x request; each |
| 1474 | bit represents a request, from 301 to 303 */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1475 | bool free_referer; /* set TRUE if 'referer' points to a string we |
| 1476 | allocated */ |
| 1477 | void *postfields; /* if POST, set the fields' values here */ |
| 1478 | curl_seek_callback seek_func; /* function that seeks the input */ |
| 1479 | curl_off_t postfieldsize; /* if POST, this might have a size to use instead |
| 1480 | of strlen(), and then the data *may* be binary |
| 1481 | (contain zero bytes) */ |
| 1482 | unsigned short localport; /* local port number to bind to */ |
| 1483 | int localportrange; /* number of additional port numbers to test in case the |
| 1484 | 'localport' one can't be bind()ed */ |
| 1485 | curl_write_callback fwrite_func; /* function that stores the output */ |
| 1486 | curl_write_callback fwrite_header; /* function that stores headers */ |
| 1487 | curl_write_callback fwrite_rtp; /* function that stores interleaved RTP */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1488 | curl_read_callback fread_func_set; /* function that reads the input */ |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 1489 | int is_fread_set; /* boolean, has read callback been set to non-NULL? */ |
| 1490 | int is_fwrite_set; /* boolean, has write callback been set to non-NULL? */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1491 | curl_progress_callback fprogress; /* OLD and deprecated progress callback */ |
| 1492 | curl_xferinfo_callback fxferinfo; /* progress callback */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1493 | curl_debug_callback fdebug; /* function that write informational data */ |
| 1494 | curl_ioctl_callback ioctl_func; /* function for I/O control */ |
| 1495 | curl_sockopt_callback fsockopt; /* function for setting socket options */ |
| 1496 | void *sockopt_client; /* pointer to pass to the socket options callback */ |
| 1497 | curl_opensocket_callback fopensocket; /* function for checking/translating |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1498 | the address and opening the |
| 1499 | socket */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1500 | void *opensocket_client; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1501 | curl_closesocket_callback fclosesocket; /* function for closing the |
| 1502 | socket */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1503 | void *closesocket_client; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1504 | |
| 1505 | void *seek_client; /* pointer to pass to the seek callback */ |
| 1506 | /* the 3 curl_conv_callback functions below are used on non-ASCII hosts */ |
| 1507 | /* function to convert from the network encoding: */ |
| 1508 | curl_conv_callback convfromnetwork; |
| 1509 | /* function to convert to the network encoding: */ |
| 1510 | curl_conv_callback convtonetwork; |
| 1511 | /* function to convert from UTF-8 encoding: */ |
| 1512 | curl_conv_callback convfromutf8; |
| 1513 | |
| 1514 | void *progress_client; /* pointer to pass to the progress callback */ |
| 1515 | void *ioctl_client; /* pointer to pass to the ioctl callback */ |
| 1516 | long timeout; /* in milliseconds, 0 means no timeout */ |
| 1517 | long connecttimeout; /* in milliseconds, 0 means no timeout */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1518 | long accepttimeout; /* in milliseconds, 0 means no timeout */ |
Elliott Hughes | cac3980 | 2018-04-27 16:19:43 -0700 | [diff] [blame] | 1519 | long happy_eyeballs_timeout; /* in milliseconds, 0 is a valid value */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1520 | long server_response_timeout; /* in milliseconds, 0 means no timeout */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1521 | long tftp_blksize; /* in bytes, 0 means use default */ |
| 1522 | bool tftp_no_options; /* do not send TFTP options requests */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1523 | curl_off_t filesize; /* size of file to upload, -1 means unknown */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1524 | long low_speed_limit; /* bytes/second */ |
| 1525 | long low_speed_time; /* number of seconds */ |
| 1526 | curl_off_t max_send_speed; /* high speed limit in bytes/second for upload */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1527 | curl_off_t max_recv_speed; /* high speed limit in bytes/second for |
| 1528 | download */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1529 | curl_off_t set_resume_from; /* continue [ftp] transfer from here */ |
| 1530 | struct curl_slist *headers; /* linked list of extra headers */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1531 | struct curl_slist *proxyheaders; /* linked list of extra CONNECT headers */ |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 1532 | struct curl_httppost *httppost; /* linked list of old POST data */ |
| 1533 | curl_mimepart mimepost; /* MIME/POST data. */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1534 | bool sep_headers; /* handle host and proxy headers separately */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1535 | bool cookiesession; /* new cookie session? */ |
| 1536 | bool crlf; /* convert crlf on ftp upload(?) */ |
| 1537 | struct curl_slist *quote; /* after connection is established */ |
| 1538 | struct curl_slist *postquote; /* after the transfer */ |
| 1539 | struct curl_slist *prequote; /* before the transfer, after type */ |
| 1540 | struct curl_slist *source_quote; /* 3rd party quote */ |
| 1541 | struct curl_slist *source_prequote; /* in 3rd party transfer mode - before |
| 1542 | the transfer on source host */ |
| 1543 | struct curl_slist *source_postquote; /* in 3rd party transfer mode - after |
| 1544 | the transfer on source host */ |
| 1545 | struct curl_slist *telnet_options; /* linked list of telnet options */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1546 | struct curl_slist *resolve; /* list of names to add/remove from |
| 1547 | DNS cache */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1548 | struct curl_slist *connect_to; /* list of host:port mappings to override |
| 1549 | the hostname and port to connect to */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1550 | curl_TimeCond timecondition; /* kind of time/date comparison */ |
| 1551 | time_t timevalue; /* what time to compare with */ |
| 1552 | Curl_HttpReq httpreq; /* what kind of HTTP request (if any) is this */ |
| 1553 | long httpversion; /* when non-zero, a specific HTTP version requested to |
| 1554 | be used in the library's request(s) */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1555 | bool strip_path_slash; /* strip off initial slash from path */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1556 | struct ssl_config_data ssl; /* user defined SSL stuff */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1557 | struct ssl_config_data proxy_ssl; /* user defined SSL stuff for proxy */ |
| 1558 | struct ssl_general_config general_ssl; /* general user defined SSL stuff */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1559 | curl_proxytype proxytype; /* what kind of proxy that is in use */ |
| 1560 | long dns_cache_timeout; /* DNS cache timeout */ |
| 1561 | long buffer_size; /* size of receive buffer to use */ |
| 1562 | void *private_data; /* application-private data */ |
| 1563 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1564 | struct curl_slist *http200aliases; /* linked list of aliases for http200 */ |
| 1565 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1566 | long ipver; /* the CURL_IPRESOLVE_* defines in the public header file |
| 1567 | 0 - whatever, 1 - v2, 2 - v6 */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1568 | |
| 1569 | curl_off_t max_filesize; /* Maximum file size to download */ |
| 1570 | |
| 1571 | curl_ftpfile ftp_filemethod; /* how to get to a file when FTP is used */ |
| 1572 | |
| 1573 | int ftp_create_missing_dirs; /* 1 - create directories that don't exist |
| 1574 | 2 - the same but also allow MKD to fail once |
| 1575 | */ |
| 1576 | |
| 1577 | curl_sshkeycallback ssh_keyfunc; /* key matching callback */ |
| 1578 | void *ssh_keyfunc_userp; /* custom pointer to callback */ |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 1579 | bool ssh_compression; /* enable SSH compression */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1580 | |
| 1581 | /* Here follows boolean settings that define how to behave during |
| 1582 | this session. They are STATIC, set by libcurl users or at least initially |
| 1583 | and they don't change during operations. */ |
| 1584 | |
| 1585 | bool printhost; /* printing host name in debug info */ |
| 1586 | bool get_filetime; /* get the time and get of the remote file */ |
| 1587 | bool tunnel_thru_httpproxy; /* use CONNECT through a HTTP proxy */ |
| 1588 | bool prefer_ascii; /* ASCII rather than binary */ |
| 1589 | bool ftp_append; /* append, not overwrite, on upload */ |
| 1590 | bool ftp_list_only; /* switch FTP command for listing directories */ |
| 1591 | bool ftp_use_port; /* use the FTP PORT command */ |
| 1592 | bool hide_progress; /* don't use the progress meter */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1593 | bool http_fail_on_error; /* fail on HTTP error codes >= 400 */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 1594 | bool http_keep_sending_on_error; /* for HTTP status codes >= 300 */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1595 | bool http_follow_location; /* follow HTTP redirects */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1596 | bool http_transfer_encoding; /* request compressed HTTP transfer-encoding */ |
Elliott Hughes | 0128fe4 | 2018-02-27 14:57:55 -0800 | [diff] [blame] | 1597 | bool allow_auth_to_other_hosts; |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1598 | bool include_header; /* include received protocol headers in data output */ |
| 1599 | bool http_set_referer; /* is a custom referer used */ |
| 1600 | bool http_auto_referer; /* set "correct" referer when following location: */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1601 | bool opt_no_body; /* as set with CURLOPT_NOBODY */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1602 | bool upload; /* upload request */ |
| 1603 | enum CURL_NETRC_OPTION |
| 1604 | use_netrc; /* defined in include/curl.h */ |
| 1605 | bool verbose; /* output verbosity */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1606 | bool krb; /* Kerberos connection requested */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1607 | bool reuse_forbid; /* forbidden to be reused, close after use */ |
| 1608 | bool reuse_fresh; /* do not re-use an existing connection */ |
| 1609 | bool ftp_use_epsv; /* if EPSV is to be attempted or not */ |
| 1610 | bool ftp_use_eprt; /* if EPRT is to be attempted or not */ |
| 1611 | bool ftp_use_pret; /* if PRET is to be used before PASV or not */ |
| 1612 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1613 | curl_usessl use_ssl; /* if AUTH TLS is to be attempted etc, for FTP or |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1614 | IMAP or POP3 or others! */ |
| 1615 | curl_ftpauth ftpsslauth; /* what AUTH XXX to be attempted */ |
| 1616 | curl_ftpccc ftp_ccc; /* FTP CCC options */ |
| 1617 | bool no_signal; /* do not use any signal/alarm handler */ |
| 1618 | bool global_dns_cache; /* subject for future removal */ |
| 1619 | bool tcp_nodelay; /* whether to enable TCP_NODELAY or not */ |
| 1620 | bool ignorecl; /* ignore content length */ |
| 1621 | bool ftp_skip_ip; /* skip the IP address the FTP server passes on to |
| 1622 | us */ |
| 1623 | bool connect_only; /* make connection, let application use the socket */ |
| 1624 | long ssh_auth_types; /* allowed SSH auth types */ |
| 1625 | bool http_te_skip; /* pass the raw body data to the user, even when |
| 1626 | transfer-encoded (chunked, compressed) */ |
| 1627 | bool http_ce_skip; /* pass the raw body data to the user, even when |
| 1628 | content-encoded (chunked, compressed) */ |
| 1629 | long new_file_perms; /* Permissions to use when creating remote files */ |
| 1630 | long new_directory_perms; /* Permissions to use when creating remote dirs */ |
| 1631 | bool proxy_transfer_mode; /* set transfer mode (;type=<a|i>) when doing FTP |
| 1632 | via an HTTP proxy */ |
| 1633 | char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1634 | unsigned int scope_id; /* Scope id for IPv6 */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1635 | long allowed_protocols; |
| 1636 | long redir_protocols; |
| 1637 | #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1638 | bool socks5_gssapi_nec; /* Flag to support NEC SOCKS5 server */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1639 | #endif |
| 1640 | struct curl_slist *mail_rcpt; /* linked list of mail recipients */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1641 | bool sasl_ir; /* Enable/disable SASL initial response */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1642 | /* Common RTSP header options */ |
| 1643 | Curl_RtspReq rtspreq; /* RTSP request type */ |
| 1644 | long rtspversion; /* like httpversion, for RTSP */ |
Alex Deymo | 486467e | 2017-12-19 19:04:07 +0100 | [diff] [blame] | 1645 | bool wildcard_enabled; /* enable wildcard matching */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1646 | curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer |
| 1647 | starts */ |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 1648 | curl_chunk_end_callback chunk_end; /* called after part transferring |
| 1649 | stopped */ |
| 1650 | curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds |
| 1651 | to pattern (e.g. if WILDCARDMATCH is on) */ |
| 1652 | void *fnmatch_data; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1653 | |
| 1654 | long gssapi_delegation; /* GSS-API credential delegation, see the |
| 1655 | documentation of CURLOPT_GSSAPI_DELEGATION */ |
| 1656 | |
| 1657 | bool tcp_keepalive; /* use TCP keepalives */ |
| 1658 | long tcp_keepidle; /* seconds in idle before sending keepalive probe */ |
| 1659 | long tcp_keepintvl; /* seconds between TCP keepalive probes */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1660 | bool tcp_fastopen; /* use TCP Fast Open */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1661 | |
| 1662 | size_t maxconnects; /* Max idle connections in the connection cache */ |
| 1663 | |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1664 | bool ssl_enable_npn; /* TLS NPN extension? */ |
| 1665 | bool ssl_enable_alpn; /* TLS ALPN extension? */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1666 | bool path_as_is; /* allow dotdots? */ |
| 1667 | bool pipewait; /* wait for pipe/multiplex status before starting a |
| 1668 | new connection */ |
| 1669 | long expect_100_timeout; /* in milliseconds */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1670 | bool suppress_connect_headers; /* suppress proxy CONNECT response headers |
| 1671 | from user callbacks */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1672 | |
Elliott Hughes | 1ef06ba | 2018-05-30 15:43:58 -0700 | [diff] [blame] | 1673 | bool dns_shuffle_addresses; /* whether to shuffle addresses before use */ |
| 1674 | |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 1675 | struct Curl_easy *stream_depends_on; |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 1676 | bool stream_depends_e; /* set or don't set the Exclusive bit */ |
| 1677 | int stream_weight; |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1678 | |
Elliott Hughes | 1ef06ba | 2018-05-30 15:43:58 -0700 | [diff] [blame] | 1679 | bool haproxyprotocol; /* whether to send HAProxy PROXY protocol header */ |
| 1680 | |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1681 | struct Curl_http2_dep *stream_dependents; |
| 1682 | |
| 1683 | bool abstract_unix_socket; |
Elliott Hughes | cac3980 | 2018-04-27 16:19:43 -0700 | [diff] [blame] | 1684 | |
| 1685 | curl_resolver_start_callback resolver_start; /* optional callback called |
| 1686 | before resolver start */ |
| 1687 | void *resolver_start_client; /* pointer to pass to resolver start callback */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1688 | }; |
| 1689 | |
| 1690 | struct Names { |
| 1691 | struct curl_hash *hostcache; |
| 1692 | enum { |
| 1693 | HCACHE_NONE, /* not pointing to anything */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1694 | HCACHE_GLOBAL, /* points to the (shrug) global one */ |
| 1695 | HCACHE_MULTI, /* points to a shared one in the multi handle */ |
| 1696 | HCACHE_SHARED /* points to a shared one in a shared object */ |
| 1697 | } hostcachetype; |
| 1698 | }; |
| 1699 | |
| 1700 | /* |
| 1701 | * The 'connectdata' struct MUST have all the connection oriented stuff as we |
| 1702 | * may have several simultaneous connections and connection structs in memory. |
| 1703 | * |
| 1704 | * The 'struct UserDefined' must only contain data that is set once to go for |
| 1705 | * many (perhaps) independent connections. Values that are generated or |
| 1706 | * calculated internally for the "session handle" must be defined within the |
| 1707 | * 'struct UrlState' instead. |
| 1708 | */ |
| 1709 | |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 1710 | struct Curl_easy { |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1711 | /* first, two fields for the linked list of these */ |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 1712 | struct Curl_easy *next; |
| 1713 | struct Curl_easy *prev; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1714 | |
| 1715 | struct connectdata *easy_conn; /* the "unit's" connection */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 1716 | struct curl_llist_element connect_queue; |
| 1717 | struct curl_llist_element pipeline_queue; |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1718 | |
| 1719 | CURLMstate mstate; /* the handle's state */ |
| 1720 | CURLcode result; /* previous result */ |
| 1721 | |
| 1722 | struct Curl_message msg; /* A single posted message. */ |
| 1723 | |
| 1724 | /* Array with the plain socket numbers this handle takes care of, in no |
| 1725 | particular order. Note that all sockets are added to the sockhash, where |
| 1726 | the state etc are also kept. This array is mostly used to detect when a |
| 1727 | socket is to be removed from the hash. See singlesocket(). */ |
| 1728 | curl_socket_t sockets[MAX_SOCKSPEREASYHANDLE]; |
| 1729 | int numsocks; |
| 1730 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1731 | struct Names dns; |
| 1732 | struct Curl_multi *multi; /* if non-NULL, points to the multi handle |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1733 | struct to which this "belongs" when used by |
| 1734 | the multi interface */ |
| 1735 | struct Curl_multi *multi_easy; /* if non-NULL, points to the multi handle |
| 1736 | struct to which this "belongs" when used |
| 1737 | by the easy interface */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1738 | struct Curl_share *share; /* Share, handles global variable mutexing */ |
| 1739 | struct SingleRequest req; /* Request-specific data */ |
| 1740 | struct UserDefined set; /* values set by the libcurl user */ |
| 1741 | struct DynamicStatic change; /* possibly modified userdefined data */ |
| 1742 | struct CookieInfo *cookies; /* the cookies, read from files and servers. |
| 1743 | NOTE that the 'cookie' field in the |
| 1744 | UserDefined struct defines if the "engine" |
| 1745 | is to be used or not. */ |
| 1746 | struct Progress progress; /* for all the progress meter data */ |
| 1747 | struct UrlState state; /* struct for fields used for state info and |
| 1748 | other dynamic purposes */ |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 1749 | struct WildcardData wildcard; /* wildcard download state info */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1750 | struct PureInfo info; /* stats, reports and info data */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1751 | struct curl_tlssessioninfo tsi; /* Information about the TLS session, only |
| 1752 | valid after a client has asked for it */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 1753 | #if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV) |
| 1754 | iconv_t outbound_cd; /* for translating to the network encoding */ |
| 1755 | iconv_t inbound_cd; /* for translating from the network encoding */ |
| 1756 | iconv_t utf8_cd; /* for translating to UTF8 */ |
| 1757 | #endif /* CURL_DOES_CONVERSIONS && HAVE_ICONV */ |
| 1758 | unsigned int magic; /* set to a CURLEASY_MAGIC_NUMBER */ |
| 1759 | }; |
| 1760 | |
| 1761 | #define LIBCURL_NAME "libcurl" |
| 1762 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1763 | #endif /* HEADER_CURL_URLDATA_H */ |