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