VirtualBox

source: vbox/trunk/src/libs/curl-7.87.0/lib/urldata.h@ 98339

最後變更 在這個檔案從98339是 98326,由 vboxsync 提交於 2 年 前

curl-7.87.0: Applied and adjusted our curl changes to 7.83.1. bugref:10356

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette