quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

urldata.h (71755B)


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