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