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