comparison mupdf-source/thirdparty/curl/lib/urldata.h @ 2:b50eed0cc0ef upstream

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