Debian Codegraph @

extra/curl/curl-8.14.1/lib/urldata.h

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