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