Coverage Report

Created: 2026-09-04 07:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/curl/lib/urldata.h
Line
Count
Source
1
#ifndef HEADER_CURL_URLDATA_H
2
#define HEADER_CURL_URLDATA_H
3
/***************************************************************************
4
 *                                  _   _ ____  _
5
 *  Project                     ___| | | |  _ \| |
6
 *                             / __| | | | |_) | |
7
 *                            | (__| |_| |  _ <| |___
8
 *                             \___|\___/|_| \_\_____|
9
 *
10
 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11
 *
12
 * This software is licensed as described in the file COPYING, which
13
 * you should have received as part of this distribution. The terms
14
 * are also available at https://curl.se/docs/copyright.html.
15
 *
16
 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17
 * copies of the Software, and permit persons to whom the Software is
18
 * furnished to do so, under the terms of the COPYING file.
19
 *
20
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21
 * KIND, either express or implied.
22
 *
23
 * SPDX-License-Identifier: curl
24
 *
25
 ***************************************************************************/
26
/* This file is for lib internal stuff */
27
#include "curl_setup.h"
28
29
0
#define CURL_DEFAULT_USER     "anonymous"
30
0
#define CURL_DEFAULT_PASSWORD "ftp@example.com"
31
32
#if !defined(_WIN32) && !defined(MSDOS)
33
/* do FTP line-end CRLF => LF conversions on platforms that prefer LF-only. It
34
   also means: keep CRLF line endings on the CRLF platforms */
35
#define CURL_PREFER_LF_LINEENDS
36
#endif
37
38
23.6k
#define DEFAULT_CONNCACHE_SIZE 5
39
40
/* length of longest IPv6 address string including the null-terminator */
41
6.24k
#define MAX_IPADR_LEN sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")
42
43
/* Max string input length is a precaution against abuse and to detect junk
44
   input easier and better. */
45
129k
#define CURL_MAX_INPUT_LENGTH 8000000
46
47
#ifdef HAVE_NETINET_IN_H
48
#include <netinet/in.h>
49
#endif
50
#ifdef HAVE_NETINET_IN6_H
51
#include <netinet/in6.h>
52
#endif
53
54
#include "curlx/timeval.h"
55
56
#include "api.h"
57
#include "cookie.h"
58
#include "creds.h"
59
#include "psl.h"
60
#include "formdata.h"
61
#include "http_chunks.h" /* for the structs and enum stuff */
62
#include "hash.h"
63
#include "peer.h"
64
#include "proxy.h"
65
#include "splay.h"
66
#include "curlx/dynbuf.h"
67
#include "bufref.h"
68
#include "dynhds.h"
69
#include "request.h"
70
#include "ratelimit.h"
71
#include "netrc.h"
72
#include "uint-hashset.h"
73
#include "vdns/asyn.h"
74
#include "vdns/hostip.h"
75
#include "vtls/vtls_config.h"
76
77
/* On error return, the value of `pnwritten` has no meaning */
78
typedef CURLcode (Curl_send)(struct Curl_easy *data,   /* transfer */
79
                             int8_t sockindex,            /* socketindex */
80
                             const uint8_t *buf,       /* data to write */
81
                             size_t len,               /* amount to send */
82
                             bool eos,                 /* last chunk */
83
                             size_t *pnwritten);       /* how much sent */
84
85
/* On error return, the value of `pnread` has no meaning */
86
typedef CURLcode (Curl_recv)(struct Curl_easy *data,   /* transfer */
87
                             int8_t sockindex,            /* socketindex */
88
                             char *buf,                /* store data here */
89
                             size_t len,               /* max amount to read */
90
                             size_t *pnread);          /* how much received */
91
92
#include "mime.h"
93
#include "protocol.h"
94
#include "ftp.h"
95
#include "http.h"
96
#include "smb.h"
97
#include "mqtt.h"
98
#include "ftplistparser.h"
99
#include "multihandle.h"
100
#include "cf-socket.h"
101
102
#ifdef HAVE_GSSAPI
103
#  ifdef HAVE_GSSAPPLE
104
#    include <GSS/gssapi.h>
105
#    include <GSS/gssapi_oid.h>
106
#  elif defined(HAVE_GSSGNU)
107
#    include <gss.h>
108
#  elif defined(HAVE_GSSAPI_H)
109
#    include <gssapi.h>
110
#  else /* MIT Kerberos */
111
#    include <gssapi/gssapi.h>
112
#    include <gssapi/gssapi_krb5.h> /* for GSS_C_CHANNEL_BOUND_FLAG in 1.19+ */
113
#  endif
114
#endif
115
116
#ifdef USE_LIBSSH2
117
#include <libssh2.h>
118
#include <libssh2_sftp.h>
119
#endif /* USE_LIBSSH2 */
120
121
23.6k
#define READBUFFER_SIZE CURL_MAX_WRITE_SIZE
122
84
#define READBUFFER_MAX  CURL_MAX_READ_SIZE
123
84
#define READBUFFER_MIN  1024
124
125
/* The default upload buffer size, should not be smaller than
126
   CURL_MAX_WRITE_SIZE, as it needs to hold a full buffer as could be sent in
127
   a write callback.
128
129
   The size was 16KB for many years but was bumped to 64KB because it makes
130
   libcurl able to do significantly faster uploads in some circumstances. Even
131
   larger buffers can help further, but this is deemed a fair memory/speed
132
   compromise. */
133
23.6k
#define UPLOADBUFFER_DEFAULT 65536
134
295
#define UPLOADBUFFER_MAX     (2 * 1024 * 1024)
135
295
#define UPLOADBUFFER_MIN     CURL_MAX_WRITE_SIZE
136
137
#ifdef USE_WINDOWS_SSPI
138
#include "curl_sspi.h"
139
#endif
140
141
#ifndef CURL_DISABLE_DIGEST_AUTH
142
/* Struct used for Digest challenge-response authentication */
143
struct digestdata {
144
  struct Curl_creds *creds;
145
  struct Curl_peer *origin;
146
#ifdef USE_WINDOWS_SSPI
147
  BYTE *input_token;
148
  size_t input_token_len;
149
  CtxtHandle *http_context;
150
#else
151
  char *nonce;
152
  char *cnonce;
153
  char *realm;
154
  char *opaque;
155
  char *qop;
156
  char *algorithm;
157
  int nc; /* nonce count */
158
  uint8_t algo;
159
  BIT(stale); /* set true for re-negotiation */
160
  BIT(userhash);
161
#endif
162
};
163
#endif
164
165
typedef enum {
166
  NTLMSTATE_NONE,
167
  NTLMSTATE_TYPE1,
168
  NTLMSTATE_TYPE2,
169
  NTLMSTATE_TYPE3,
170
  NTLMSTATE_LAST
171
} curlntlm;
172
173
typedef enum {
174
  GSS_AUTHNONE,
175
  GSS_AUTHRECV,
176
  GSS_AUTHSENT,
177
  GSS_AUTHDONE,
178
  GSS_AUTHSUCC
179
} curlnegotiate;
180
181
/*
182
 * Boolean values that concerns this connection.
183
 */
184
struct ConnectBits {
185
  BIT(connect_only);
186
#ifndef CURL_DISABLE_PROXY
187
  BIT(origin_is_proxy);  /* if set, the connection's origin is a proxy */
188
#endif
189
  /* always modify bits.close with the connclose() and connkeep() macros! */
190
  BIT(close); /* if set, we close the connection after this request */
191
  BIT(reuse); /* if set, this is a reused connection */
192
  BIT(altused); /* this is an alt-svc "redirect" */
193
  BIT(ipv6);    /* we communicate with a site using an IPv6 address */
194
  BIT(do_more); /* this is set TRUE if the ->curl_do_more() function is
195
                   supposed to be called, after ->curl_do() */
196
  BIT(protoconnstart);/* the protocol layer has STARTED its operation after
197
                         the TCP layer connect */
198
  BIT(retry);         /* this connection is about to get closed and then
199
                         re-attempted at another connection. */
200
#ifndef CURL_DISABLE_FTP
201
  BIT(ftp_use_epsv);  /* As set with CURLOPT_FTP_USE_EPSV, but if we find out
202
                         EPSV does not work we disable it for the forthcoming
203
                         requests */
204
  BIT(ftp_use_eprt);  /* As set with CURLOPT_FTP_USE_EPRT, but if we find out
205
                         EPRT does not work we disable it for the forthcoming
206
                         requests */
207
  BIT(ftp_use_data_ssl); /* Enabled SSL for the data connection */
208
#endif
209
  BIT(bound); /* set true if bind() has already been done on this socket/
210
                 connection */
211
  BIT(upgrade_in_progress); /* protocol upgrade is in progress */
212
  BIT(multiplex); /* connection is multiplexed */
213
  BIT(tcp_fastopen); /* use TCP Fast Open */
214
  BIT(tls_enable_alpn); /* TLS ALPN extension? */
215
  BIT(sock_accepted); /* TRUE if the SECONDARYSOCKET was created with
216
                         accept() */
217
  BIT(parallel_connect); /* set TRUE when a parallel connect attempt has
218
                            started (happy eyeballs) */
219
  BIT(aborted); /* connection was aborted, e.g. in unclean state */
220
  BIT(no_reuse); /* connection should not be reused */
221
  BIT(shutdown_handler); /* connection shutdown: handler shut down */
222
  BIT(shutdown_filters); /* connection shutdown: filters shut down */
223
  BIT(in_cpool);     /* connection is kept in a connection pool */
224
  BIT(dns_resolved); /* DNS records for connection were resolved */
225
};
226
227
struct hostname {
228
  char *rawalloc; /* allocated "raw" version of the name */
229
  char *encalloc; /* allocated IDN-encoded version of the name */
230
  char *name;     /* name to use internally, might be encoded, might be raw */
231
  const char *dispname; /* name to display, as 'name' might be encoded */
232
};
233
234
172k
#define FIRSTSOCKET     0
235
68.5k
#define SECONDARYSOCKET 1
236
237
2.81k
#define TRNSPRT_NONE 0
238
30.5k
#define TRNSPRT_TCP  3
239
1.25k
#define TRNSPRT_UDP  4
240
5.59k
#define TRNSPRT_QUIC 5
241
6.32k
#define TRNSPRT_UNIX 6
242
243
1.25k
#define TRNSPRT_IS_DGRAM(x)   (((x) == TRNSPRT_UDP) || ((x) == TRNSPRT_QUIC))
244
245
struct ip_quadruple {
246
  char remote_ip[MAX_IPADR_LEN];
247
  char local_ip[MAX_IPADR_LEN];
248
  uint16_t remote_port;
249
  uint16_t local_port;
250
  uint8_t transport;
251
};
252
253
#define CUR_IP_QUAD_HAS_PORTS(x)      \
254
0
  (((x)->transport == TRNSPRT_TCP) || \
255
0
   ((x)->transport == TRNSPRT_UDP) || \
256
0
   ((x)->transport == TRNSPRT_QUIC))
257
258
/*
259
 * The connectdata struct contains all fields and variables that should be
260
 * unique for an entire connection.
261
 */
262
struct connectdata {
263
  curl_off_t connection_id; /* Contains a unique number to make it easier to
264
                               track the connections in the log output */
265
266
  /* A connection cache from a SHARE might be used in several multi handles.
267
   * We MUST not reuse connections that are running in another multi,
268
   * for concurrency reasons. That multi might run in another thread.
269
   * `attached_multi` is set by the first transfer attached and cleared
270
   * when the last one is detached.
271
   * NEVER call anything on this multi, check for equality. */
272
  struct Curl_multi *attached_multi;
273
274
  /* Who the connection is talking to, ultimately */
275
  struct Curl_peer *origin; /* connection ultimately talks to this */
276
  struct Curl_peer *via_peer; /* if set, connection really talks to this */
277
  struct Curl_peer *origin2; /* origin of SECONDARYSOCKET */
278
  struct Curl_peer *via_peer2; /* peer of SECONDARYSOCKET */
279
  struct Curl_creds *creds; /* When connection itself is tied to credentials */
280
  struct Curl_peer *creds_origin; /* origin tied credentials are for */
281
  const struct Curl_scheme *scheme; /* Connection's real protocol handler */
282
  const struct Curl_scheme *given;   /* The protocol first given */
283
284
  /* `meta_hash` is a general key-value store for implementations
285
   * with the lifetime of the connection.
286
   * Elements need to be added with their own destructor to be invoked when
287
   * the connection is cleaned up (see Curl_hash_add2()).*/
288
  struct Curl_hash meta_hash;
289
290
  struct Curl_llist_node cpool_node; /* conncache lists */
291
  struct Curl_llist_node cshutdn_node; /* cshutdn list */
292
  char *destination; /* hostname+port, used in conncache */
293
294
  struct curltime created; /* creation time */
295
  /* timediff_t are deltas from `created`*/
296
  timediff_t lastused_ms; /* when returned to the connection pool as idle */
297
  timediff_t lastchecked_ms; /* when last checked alive status */
298
  timediff_t lastupkeep_ms; /* when last done conn_upkeep */
299
300
#ifndef CURL_DISABLE_PROXY
301
  struct proxy_info socks_proxy;
302
  struct proxy_info http_proxy;
303
#endif
304
305
  struct Curl_cfilter *cfilter[2]; /* connection filters */
306
  Curl_recv *recv[2];
307
  Curl_send *send[2];
308
  /* A connection can have one or two sockets and connection filters.
309
   * The protocol using the 2nd one is FTP for CONTROL+DATA sockets */
310
  curl_socket_t sock[2];
311
312
118k
#define CONN_SOCK_IDX_VALID(i)    (((i) >= 0) && ((i) < 2))
313
314
  struct {
315
    timediff_t start_ms[2]; /* when filter shutdown started */
316
    timediff_t timeout_ms; /* 0 means no timeout */
317
  } shutdown;
318
319
  curl_closesocket_callback fclosesocket; /* function closing the socket(s) */
320
  void *closesocket_client;
321
322
  struct ssl_primary_config ssl_config;
323
#ifndef CURL_DISABLE_PROXY
324
  struct ssl_primary_config proxy_ssl_config;
325
#endif
326
  char *options; /* options string, allocated */
327
328
  /*************** Request - specific items ************/
329
#ifdef USE_WINDOWS_SSPI
330
  CtxtHandle *sslContext;
331
#endif
332
333
#ifdef USE_NTLM
334
  curlntlm http_ntlm_state;
335
  curlntlm proxy_ntlm_state;
336
#endif
337
338
#ifdef USE_SPNEGO
339
  curlnegotiate http_negotiate_state;
340
  curlnegotiate proxy_negotiate_state;
341
#endif
342
343
  /* When this connection is created, store the conditions for the local end
344
     bind. This is stored before the actual bind and before any connection is
345
     made and will serve the purpose of being used for comparison reasons so
346
     that subsequent bound-requested connections are not accidentally reusing
347
     wrong connections. */
348
  char *localdev;
349
  struct ConnectBits bits;    /* various state-flags for this connection */
350
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
351
  int socks5_gssapi_enctype;
352
#endif
353
354
  /* This is used by the connection pool logic. If this returns TRUE, this
355
     handle is still used by one or more easy handles and can only used by any
356
     other easy handle without careful consideration (== only for
357
     multiplexing) and it cannot be used by another multi handle! */
358
29.9k
#define CONN_INUSE(c) (!!(c)->attached_xfers)
359
  uint32_t attached_xfers; /* # of attached easy handles */
360
361
#ifdef USE_IPV6
362
  uint32_t scope_id;  /* Scope id for IPv6 */
363
#endif
364
  uint16_t localportrange;
365
  uint16_t localport;
366
  int8_t recv_idx;  /* on which socket index to receive, default 0 */
367
  int8_t send_idx;  /* on which socket index to send, default 0 */
368
  uint8_t transport_wanted; /* one of the TRNSPRT_* defines. Not necessarily
369
   the transport the connection ends using due to Alt-Svc and happy
370
   eyeballing. Use Curl_conn_get_transport() for actual value once the
371
   connection is set up. */
372
  uint8_t ip_version; /* copied from the Curl_easy at creation time */
373
  /* HTTP version last responded with by the server or negotiated via ALPN.
374
   * 0 at start, then one of 09, 10, 11, etc. */
375
  uint8_t httpversion_seen;
376
  uint8_t gssapi_delegation; /* inherited from set.gssapi_delegation */
377
378
};
379
380
#ifndef CURL_DISABLE_PROXY
381
#define CURL_CONN_HOST_DISPNAME(c) \
382
  ((c)->socks_proxy.peer ? (c)->socks_proxy.peer->user_hostname : \
383
    (c)->http_proxy.peer ? (c)->http_proxy.peer->user_hostname : \
384
      (c)->via_peer ? (c)->via_peer->user_hostname : \
385
        (c)->origin->user_hostname)
386
#else
387
#define CURL_CONN_HOST_DISPNAME(c) \
388
  ((c)->via_peer ? (c)->via_peer->user_hostname : (c)->origin->user_hostname)
389
#endif
390
391
/* The end of connectdata. */
392
393
/*
394
 * Struct to keep statistical and informational data.
395
 * All variables in this struct must be initialized/reset in Curl_initinfo().
396
 */
397
struct PureInfo {
398
  /* PureInfo primary ip_quadruple is copied over from the connectdata
399
     struct in order to allow curl_easy_getinfo() to return this information
400
     even when the session handle is no longer associated with a connection,
401
     and also allow curl_easy_reset() to clear this information from the
402
     session handle without disturbing information which is still alive, and
403
     that might be reused, in the connection pool. */
404
  struct ip_quadruple primary;
405
  struct curl_certinfo certs; /* info about the certs. Asked for with
406
                                 CURLOPT_CERTINFO / CURLINFO_CERTINFO */
407
  time_t filetime; /* If requested, this is might get set. Set to -1 if the
408
                      time was unretrievable. */
409
  curl_off_t request_size; /* the amount of bytes sent in the request(s) */
410
  curl_off_t numconnects; /* how many new connections libcurl created */
411
  char *contenttype; /* the content type of the object */
412
  char *wouldredirect; /* URL this would have been redirected to if asked to */
413
  curl_off_t retry_after; /* info from Retry-After: header */
414
  const char *conn_scheme;
415
  int httpcode;  /* Recent HTTP, FTP, RTSP or SMTP response code */
416
  int httpproxycode; /* response code from proxy when received separate */
417
  int httpversion; /* the http version number X.Y = X*10+Y */
418
  uint32_t conn_protocol;
419
  uint32_t proxyauthavail; /* what proxy auth types were announced */
420
  uint32_t httpauthavail;  /* what host auth types were announced */
421
  uint32_t proxyauthpicked; /* selected proxy auth type */
422
  uint32_t httpauthpicked;  /* selected host auth type */
423
  uint32_t header_size;  /* size of read header(s) in bytes */
424
  uint8_t pxcode; /* holds a CURLproxycode */
425
  BIT(timecond);  /* set to TRUE if the time condition did not match, which
426
                     thus made the document NOT get fetched */
427
  BIT(used_proxy); /* the transfer used a proxy */
428
};
429
430
struct pgrs_dir {
431
  curl_off_t total_size; /* total expected bytes */
432
  curl_off_t cur_size; /* transferred bytes so far */
433
  curl_off_t speed; /* bytes per second transferred */
434
  struct Curl_rlimit rlimit; /* speed limiting / pausing */
435
};
436
437
struct Progress {
438
  struct curltime now; /* current time of processing */
439
  struct curltime start; /* when transfer was initialized, set once */
440
441
  struct pgrs_dir ul;
442
  struct pgrs_dir dl;
443
  curl_off_t deliver; /* amount of data delivered to application */
444
  curl_off_t current_speed; /* uses the currently fastest transfer */
445
  curl_off_t earlydata_sent;
446
447
  struct {
448
    timediff_t startop_us; /* since start when operations started */
449
    timediff_t startsingle_us; /* since start when last request started */
450
    timediff_t startqueue_us; /* since start when last entered queueing */
451
    timediff_t startredirect_us; /* since start when last redirected */
452
    timediff_t lastshow_us; /* since start when last progress shown */
453
  } delta;
454
  struct {
455
    timediff_t spent_us; /* all time spent since start */
456
    timediff_t queued_us; /* time spent since startsingle's for queueing */
457
    timediff_t nslookup_us; /* same for name resolves */
458
    timediff_t connect_us; /* same for connects */
459
    timediff_t appconnect_us; /* same for application connects, e.g. TLS */
460
    timediff_t pretransfer_us; /* same until requests were sent */
461
    timediff_t starttransfer_us; /* same until responses started */
462
    timediff_t posttransfer_us; /* same until responses ended */
463
  } total;
464
465
64.5k
#define CURL_SPEED_RECORDS (5 + 1) /* 6 entries for 5 seconds */
466
467
  curl_off_t speed_amount[CURL_SPEED_RECORDS];
468
  timediff_t speed_time[CURL_SPEED_RECORDS];
469
  uint32_t speeder_c;
470
  BIT(hide);
471
  BIT(ul_size_known);
472
  BIT(dl_size_known);
473
  BIT(headers_out); /* when the headers have been written */
474
  BIT(callback);  /* set when progress callback is used */
475
  BIT(startransfer_added);
476
};
477
478
struct auth {
479
  uint32_t want;  /* Bitmask set to the authentication methods wanted by app
480
                     (with CURLOPT_HTTPAUTH or CURLOPT_PROXYAUTH). */
481
  uint32_t picked;
482
  uint32_t avail; /* Bitmask for what the server reports to support for this
483
                     resource */
484
  BIT(done);  /* TRUE when the auth phase is done and ready to do the
485
                 actual request */
486
  BIT(multipass); /* TRUE if this is not yet authenticated but within the
487
                     auth multipass negotiation */
488
};
489
490
#ifdef USE_NGHTTP2
491
struct Curl_data_prio_node {
492
  struct Curl_data_prio_node *next;
493
  struct Curl_easy *data;
494
};
495
#endif
496
497
/* Timers */
498
typedef enum {
499
  EXPIRE_100_TIMEOUT,
500
  EXPIRE_ASYNC_NAME,
501
  EXPIRE_CONNECTTIMEOUT,
502
  EXPIRE_HAPPY_EYEBALLS,
503
  EXPIRE_MULTI_PENDING,
504
  EXPIRE_SPEEDCHECK,
505
  EXPIRE_TIMEOUT,
506
  EXPIRE_TOOFAST,
507
  EXPIRE_QUIC,
508
  EXPIRE_FTP_ACCEPT,
509
  EXPIRE_ALPN_EYEBALLS,
510
  EXPIRE_SHUTDOWN,
511
  EXPIRE_LAST /* not an actual timer, used as a marker only */
512
} expire_id;
513
514
struct expire_timers {
515
  struct Curl_tree splaynode; /* for the splay stuff */
516
  /* microsecond offset from Curl_timeouts base timestamp */
517
  timediff_t offset_us[EXPIRE_LAST];
518
  uint8_t next[EXPIRE_LAST];
519
  uint8_t first;
520
};
521
522
/* individual pieces of the URL */
523
struct urlpieces {
524
  char *options;
525
  char *path;
526
  char *query;
527
};
528
529
struct UrlState {
530
  curl_off_t lastconnect_id; /* The last assigned connection or -1 */
531
  /* Origin of the initial (e.g. not followed) request of a transfer.
532
     Credentials from CURLOPT_* are only valid for this origin.
533
     Always set once a transfer starts searching for connections. */
534
  struct Curl_peer *initial_origin;
535
  /* Current origin of the transfer, changes to origin of follow
536
   * requests. */
537
  struct Curl_peer *origin;
538
539
  struct curltime keeps_speed; /* for the progress meter really */
540
  struct dynbuf headerb; /* buffer to store headers in */
541
#ifndef CURL_DISABLE_HSTS
542
  struct curl_slist *hstslist; /* list of HSTS files set by
543
                                  curl_easy_setopt(HSTS) calls */
544
#endif
545
546
  int os_errno;  /* filled in with errno whenever an error occurs */
547
  int requests; /* request counter: redirects + authentication retakes */
548
#ifdef HAVE_SIGNAL
549
  /* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */
550
  void (*prev_signal)(int sig);
551
#endif
552
#ifndef CURL_DISABLE_DIGEST_AUTH
553
  char *envproxy; /* last proxy string used for proxy-related state */
554
  struct digestdata digest;      /* state data for host Digest auth */
555
  struct digestdata proxydigest; /* state data for proxy Digest auth */
556
#endif
557
  struct auth authhost;  /* auth details for host */
558
  struct auth authproxy; /* auth details for proxy */
559
560
#ifdef USE_CURL_ASYNC
561
  struct Curl_resolv_async *async;  /* asynchronous name resolver data */
562
#endif
563
564
#ifdef USE_OPENSSL
565
  /* void instead of ENGINE to avoid bleeding OpenSSL into this header */
566
  void *engine;
567
  /* void instead of OSSL_PROVIDER */
568
  void *provider;
569
  void *baseprov;
570
  void *libctx;
571
  char *propq; /* for a provider */
572
#endif /* USE_OPENSSL */
573
  struct expire_timers timeouts; /* expire timeouts */
574
575
  /* a place to store the most recently set (S)FTP entrypath */
576
  char *most_recent_ftp_entrypath;
577
  char *range; /* range, if used. See README for detailed specification on
578
                  this syntax. */
579
  curl_off_t resume_from; /* continue [ftp] transfer from here */
580
  curl_off_t infilesize; /* size of file to upload, -1 means unknown.
581
                            Copied from set.filesize at start of operation */
582
  curl_read_callback fread_func; /* read callback/function */
583
  void *in;                      /* CURLOPT_READDATA */
584
  CURLU *uh; /* URL handle for the current parsed URL */
585
  struct urlpieces up;
586
  struct bufref url;        /* work URL, initially copied from UserDefined */
587
  struct bufref referer;    /* referer string */
588
  struct curl_slist *resolve; /* set to point to the set.resolve list when
589
                                 this should be dealt with in pretransfer */
590
#ifndef CURL_DISABLE_HTTP
591
  curl_mimepart *mimepost;
592
#ifndef CURL_DISABLE_FORM_API
593
  curl_mimepart *formp; /* storage for old API form-posting, allocated on
594
                           demand */
595
#endif
596
  struct Curl_llist httphdrs; /* received headers */
597
  struct curl_header headerout[2]; /* for external purposes */
598
#endif
599
#ifndef CURL_DISABLE_COOKIES
600
  struct curl_slist *cookielist; /* list of cookie files set by
601
                                    curl_easy_setopt(COOKIEFILE) calls */
602
#endif
603
604
#ifdef CURLVERBOSE
605
  struct curl_trc_feat *feat; /* opt. trace feature transfer is part of */
606
#endif
607
608
#ifndef CURL_DISABLE_NETRC
609
  struct store_netrc netrc;
610
#endif
611
612
  struct Curl_creds *creds; /* Credentials for the origin only */
613
614
#ifndef CURL_DISABLE_HTTP
615
  char *rangeline; /* allocated */
616
  char *http_host; /* allocated */
617
  struct http_negotiation http_neg;
618
#endif
619
#ifndef CURL_DISABLE_RTSP
620
  /* This RTSP state information survives requests and connections */
621
  uint8_t rtp_channel_mask[32]; /* for the correctness checking of the
622
                                         interleaved data */
623
  uint32_t rtsp_next_client_CSeq; /* the session's next client CSeq */
624
  uint32_t rtsp_next_server_CSeq; /* the session's next server CSeq */
625
  uint32_t rtsp_CSeq_recv; /* most recent CSeq received */
626
#endif
627
#if defined(USE_HTTP2) || defined(USE_HTTP3)
628
  int weight; /* shallow copy of data->set */
629
#endif
630
  uint16_t followlocation; /* redirect counter */
631
  uint8_t retrycount; /* number of retries on a new connection, up to
632
                               CONN_MAX_RETRIES */
633
  uint8_t httpreq; /* Curl_HttpReq; what kind of HTTP request (if any)
634
                            is this */
635
636
#ifdef USE_OPENSSL
637
  BIT(provider_loaded);
638
#endif /* USE_OPENSSL */
639
  BIT(really_alive); /* transfer is really alive in multi, passed INIT */
640
  BIT(this_is_a_follow); /* this is a followed Location: request */
641
  BIT(refused_stream); /* this was refused, try again */
642
  BIT(errorbuf); /* Set to TRUE if the error buffer is already filled in.
643
                    This must be set to FALSE every time _easy_perform() is
644
                    called. */
645
  BIT(allow_port); /* Is set.use_port allowed to take effect or not. This
646
                      is always set TRUE when curl_easy_perform() is called. */
647
  BIT(authproblem); /* TRUE if there is some problem authenticating */
648
  /* set after initial USER failure, to prevent an authentication loop */
649
  BIT(wildcardmatch); /* enable wildcard matching */
650
  BIT(disableexpect);    /* TRUE if Expect: is disabled due to a previous
651
                            417 response */
652
  BIT(use_range);
653
  BIT(rangestringalloc); /* the range string is malloc()'ed */
654
  BIT(done); /* set to FALSE when Curl_init_transfer() is called and set to
655
                TRUE when multi_done() is called, to prevent multi_done() from
656
                being invoked twice. */
657
#ifndef CURL_DISABLE_COOKIES
658
  BIT(cookie_engine);
659
#endif
660
  BIT(prefer_ascii);   /* ASCII rather than binary */
661
#ifdef CURL_LIST_ONLY_PROTOCOL
662
  BIT(list_only);      /* list directory contents */
663
#endif
664
  BIT(wildcard_resolve); /* Set to true if any resolve change is a wildcard */
665
  BIT(upload);         /* upload request */
666
  BIT(internal); /* internal: true if this easy handle was created for
667
                    internal use and the user does not have ownership of the
668
                    handle. */
669
  BIT(http_ignorecustom); /* ignore custom method from now */
670
#ifndef CURL_DISABLE_HTTP
671
  BIT(http_hd_te); /* Added HTTP header TE: */
672
  BIT(http_hd_upgrade); /* Added HTTP header Upgrade: */
673
  BIT(http_hd_h2_settings); /* Added HTTP header H2Settings: */
674
  BIT(maybe_folded);
675
  BIT(leading_unfold); /* unfold started, this is the leading bytes */
676
#endif
677
};
678
679
/*
680
 * This 'UserDefined' struct must only contain data that is set once to go
681
 * for many (perhaps) independent connections. Values that are generated or
682
 * calculated internally for the "session handle" MUST be defined within the
683
 * 'struct UrlState' instead. The only exceptions MUST note the changes in
684
 * the 'DynamicStatic' struct.
685
 * Character pointer fields point to dynamic storage, unless otherwise stated.
686
 */
687
688
struct Curl_multi;    /* declared in multihandle.c */
689
690
enum dupstring {
691
  STRING_CERT,            /* client certificate filename */
692
  STRING_CERT_TYPE,       /* format for certificate (default: PEM)*/
693
  STRING_KEY,             /* private key filename */
694
  STRING_KEY_PASSWD,      /* plain text private key password */
695
  STRING_KEY_TYPE,        /* format for private key (default: PEM) */
696
  STRING_SSL_CAPATH,      /* CA directory name (does not work on Windows) */
697
  STRING_SSL_CAFILE,      /* certificate file to verify peer against */
698
  STRING_SSL_PINNEDPUBLICKEY, /* public key file to verify peer against */
699
  STRING_SSL_CIPHER_LIST, /* list of ciphers to use */
700
  STRING_SSL_CIPHER13_LIST, /* list of TLS 1.3 ciphers to use */
701
  STRING_SSL_CRLFILE,     /* CRL file to check certificate */
702
  STRING_SSL_ISSUERCERT,  /* issuer cert file to check certificate */
703
  STRING_SERVICE_NAME,    /* Service name */
704
#ifndef CURL_DISABLE_PROXY
705
  STRING_CERT_PROXY,      /* client certificate filename */
706
  STRING_CERT_TYPE_PROXY, /* format for certificate (default: PEM)*/
707
  STRING_KEY_PROXY,       /* private key filename */
708
  STRING_KEY_PASSWD_PROXY, /* plain text private key password */
709
  STRING_KEY_TYPE_PROXY,  /* format for private key (default: PEM) */
710
  STRING_SSL_CAPATH_PROXY, /* CA directory name (does not work on Windows) */
711
  STRING_SSL_CAFILE_PROXY, /* certificate file to verify peer against */
712
  STRING_SSL_PINNEDPUBLICKEY_PROXY, /* public key file to verify proxy */
713
  STRING_SSL_CIPHER_LIST_PROXY, /* list of ciphers to use */
714
  STRING_SSL_CIPHER13_LIST_PROXY, /* list of TLS 1.3 ciphers to use */
715
  STRING_SSL_CRLFILE_PROXY, /* CRL file to check certificate */
716
  STRING_SSL_ISSUERCERT_PROXY, /* issuer cert file to check certificate */
717
  STRING_PROXY_SERVICE_NAME, /* Proxy service name */
718
#endif
719
#ifndef CURL_DISABLE_COOKIES
720
  STRING_COOKIE,          /* HTTP cookie string to send */
721
  STRING_COOKIEJAR,       /* dump all cookies to this file */
722
#endif
723
  STRING_CUSTOMREQUEST,   /* HTTP/FTP/RTSP request/method to use */
724
  STRING_DEFAULT_PROTOCOL, /* Protocol to use when the URL does not specify */
725
  STRING_DEVICE,          /* local network interface/address to use */
726
  STRING_INTERFACE,       /* local network interface to use */
727
  STRING_BINDHOST,        /* local address to use */
728
  STRING_ENCODING,        /* Accept-Encoding string */
729
#ifndef CURL_DISABLE_FTP
730
  STRING_FTP_ACCOUNT,     /* ftp account data */
731
  STRING_FTP_ALTERNATIVE_TO_USER, /* command to send if USER/PASS fails */
732
  STRING_FTPPORT,         /* port to send with the FTP PORT command */
733
#endif
734
#ifndef CURL_DISABLE_NETRC
735
  STRING_NETRC_FILE,      /* if not NULL, use this instead of trying to find
736
                             $HOME/.netrc */
737
#endif
738
#ifndef CURL_DISABLE_PROXY
739
  STRING_PROXY,           /* proxy to use */
740
  STRING_PRE_PROXY,       /* pre socks proxy to use */
741
#endif
742
  STRING_SET_RANGE,       /* range, if used */
743
  STRING_SET_REFERER,     /* custom string for the HTTP referer field */
744
  STRING_SET_URL,         /* what original URL to work on */
745
  STRING_USERAGENT,       /* User-Agent string */
746
  STRING_SSL_ENGINE,      /* name of SSL engine */
747
  STRING_USERNAME,        /* <username>, if used */
748
  STRING_PASSWORD,        /* <password>, if used */
749
  STRING_OPTIONS,         /* <options>, if used */
750
#ifndef CURL_DISABLE_PROXY
751
  STRING_PROXYUSERNAME,   /* Proxy <username>, if used */
752
  STRING_PROXYPASSWORD,   /* Proxy <password>, if used */
753
  STRING_NOPROXY,         /* List of hosts which should not use the proxy, if
754
                             used */
755
#endif
756
#ifndef CURL_DISABLE_RTSP
757
  STRING_RTSP_SESSION_ID, /* Session ID to use */
758
  STRING_RTSP_STREAM_URI, /* Stream URI for this request */
759
  STRING_RTSP_TRANSPORT,  /* Transport for this session */
760
#endif
761
#ifdef USE_SSH
762
  STRING_SSH_PRIVATE_KEY, /* path to the private key file for auth */
763
  STRING_SSH_PUBLIC_KEY,  /* path to the public key file for auth */
764
  STRING_SSH_HOST_PUBLIC_KEY_MD5, /* md5 of host public key in ASCII hex */
765
  STRING_SSH_HOST_PUBLIC_KEY_SHA256, /* sha256 of host public key in base64 */
766
  STRING_SSH_KNOWNHOSTS,  /* filename of knownhosts file */
767
#endif
768
#ifndef CURL_DISABLE_SMTP
769
  STRING_MAIL_FROM,
770
  STRING_MAIL_AUTH,
771
#endif
772
  STRING_BEARER,                /* <bearer>, if used */
773
#ifdef USE_UNIX_SOCKETS
774
  STRING_UNIX_SOCKET_PATH,      /* path to Unix socket, if used */
775
#endif
776
  STRING_TARGET,                /* CURLOPT_REQUEST_TARGET */
777
#ifndef CURL_DISABLE_DOH
778
  STRING_DOH,                   /* CURLOPT_DOH_URL */
779
#endif
780
#ifndef CURL_DISABLE_ALTSVC
781
  STRING_ALTSVC,                /* CURLOPT_ALTSVC */
782
#endif
783
#ifndef CURL_DISABLE_HSTS
784
  STRING_HSTS,                  /* CURLOPT_HSTS */
785
#endif
786
  STRING_SASL_AUTHZID,          /* CURLOPT_SASL_AUTHZID */
787
#ifdef USE_ARES
788
  STRING_DNS_SERVERS,
789
  STRING_DNS_INTERFACE,
790
  STRING_DNS_LOCAL_IP4,
791
  STRING_DNS_LOCAL_IP6,
792
#endif
793
  STRING_SSL_EC_CURVES,
794
#ifndef CURL_DISABLE_AWS
795
  STRING_AWS_SIGV4, /* Parameters for V4 signature */
796
#endif
797
#ifndef CURL_DISABLE_HTTPSIG
798
  STRING_HTTPSIG_KEY,    /* hex-encoded key data */
799
  STRING_HTTPSIG_KEYID,  /* key identifier */
800
  STRING_HTTPSIG_HEADERS, /* space-separated components to sign */
801
#endif
802
#ifndef CURL_DISABLE_PROXY
803
  STRING_HAPROXY_CLIENT_IP,     /* CURLOPT_HAPROXY_CLIENT_IP */
804
#endif
805
  STRING_ECH_CONFIG,            /* CURLOPT_ECH_CONFIG */
806
  STRING_ECH_PUBLIC,            /* CURLOPT_ECH_PUBLIC */
807
  STRING_SSL_SIGNATURE_ALGORITHMS, /* CURLOPT_SSL_SIGNATURE_ALGORITHMS */
808
809
  STRING_LAST /* not used, an end-of-list marker */
810
};
811
812
enum dupblob {
813
  BLOB_CERT,
814
  BLOB_KEY,
815
  BLOB_SSL_ISSUERCERT,
816
  BLOB_CAINFO,
817
#ifndef CURL_DISABLE_PROXY
818
  BLOB_CERT_PROXY,
819
  BLOB_KEY_PROXY,
820
  BLOB_SSL_ISSUERCERT_PROXY,
821
  BLOB_CAINFO_PROXY,
822
#endif
823
  BLOB_LAST
824
};
825
826
struct UserDefined {
827
  FILE *err;         /* the stderr user data goes here */
828
  void *debugdata;   /* the data that will be passed to fdebug */
829
  char *errorbuffer; /* (Static) store failure messages in here */
830
  void *out;         /* CURLOPT_WRITEDATA */
831
  void *in_set;      /* CURLOPT_READDATA */
832
  void *writeheader; /* write the header to this if non-NULL */
833
  uint32_t httpauth;  /* kind of HTTP authentication to use (bitmask) */
834
  uint32_t proxyauth; /* kind of proxy authentication to use (bitmask) */
835
  void *postfields;  /* if POST, set the fields' values here */
836
  char *str_copypostfields; /* CURLOPT_COPYPOSTFIELDS value */
837
  curl_seek_callback seek_func;      /* function that seeks the input */
838
  curl_off_t postfieldsize; /* if POST, this might have a size to use instead
839
                               of strlen(), and then the data *may* be binary
840
                               (contain zero bytes) */
841
  curl_write_callback fwrite_func;   /* function that stores the output */
842
  curl_write_callback fwrite_header; /* function that stores headers */
843
  curl_write_callback fwrite_rtp;    /* function that stores interleaved RTP */
844
  curl_read_callback fread_func_set; /* function that reads the input */
845
  curl_progress_callback fprogress; /* OLD and deprecated progress callback */
846
  curl_xferinfo_callback fxferinfo; /* progress callback */
847
  curl_debug_callback fdebug;      /* function that write informational data */
848
  curl_ioctl_callback ioctl_func;  /* function for I/O control */
849
  curl_sockopt_callback fsockopt;  /* function for setting socket options */
850
  void *sockopt_client; /* pointer to pass to the socket options callback */
851
  curl_opensocket_callback fopensocket; /* function for checking/translating
852
                                           the address and opening the
853
                                           socket */
854
  void *opensocket_client;
855
  curl_closesocket_callback fclosesocket; /* function for closing the
856
                                             socket */
857
  void *closesocket_client;
858
  curl_prereq_callback fprereq; /* pre-initial request callback */
859
  void *prereq_userp; /* pre-initial request user data */
860
861
  void *seek_client;    /* pointer to pass to the seek callback */
862
#ifndef CURL_DISABLE_HSTS
863
  curl_hstsread_callback hsts_read;
864
  void *hsts_read_userp;
865
  curl_hstswrite_callback hsts_write;
866
  void *hsts_write_userp;
867
#endif
868
  void *progress_client; /* pointer to pass to the progress callback */
869
  void *ioctl_client;   /* pointer to pass to the ioctl callback */
870
  timediff_t conn_max_idle_ms; /* max idle time to allow a connection that
871
                                  is to be reused */
872
  timediff_t conn_max_age_ms; /* max time since creation to allow a
873
                                 connection that is to be reused */
874
  curl_off_t filesize;  /* size of file to upload, -1 means unknown */
875
  curl_off_t low_speed_limit; /* bytes/second */
876
  curl_off_t max_send_speed; /* high speed limit in bytes/second for upload */
877
  curl_off_t max_recv_speed; /* high speed limit in bytes/second for
878
                                download */
879
  curl_off_t set_resume_from;  /* continue [ftp] transfer from here */
880
  struct curl_slist *headers; /* linked list of extra headers */
881
  struct curl_httppost *httppost;  /* linked list of old POST data */
882
#if !defined(CURL_DISABLE_MIME) || !defined(CURL_DISABLE_FORM_API)
883
  curl_mimepart *mimepostp;  /* MIME/POST data. */
884
#endif
885
#ifndef CURL_DISABLE_TELNET
886
  struct curl_slist *telnet_options; /* linked list of telnet options */
887
#endif
888
  struct curl_slist *resolve;     /* list of names to add/remove from
889
                                     DNS cache */
890
  struct curl_slist *connect_to; /* list of host:port mappings to override
891
                                    the hostname and port to connect to */
892
  time_t timevalue;       /* what time to compare with */
893
  struct ssl_config_data ssl;  /* user defined SSL stuff */
894
#ifndef CURL_DISABLE_PROXY
895
  struct ssl_config_data proxy_ssl;  /* user defined SSL stuff for proxy */
896
  struct curl_slist *proxyheaders; /* linked list of extra CONNECT headers */
897
  uint16_t proxyport;       /* If non-zero, use this port number by
898
                               default. If the proxy string features a
899
                               ":[port]" that one will override this. */
900
  uint8_t proxytype; /* what kind of proxy */
901
  uint8_t socks5auth;/* kind of SOCKS5 authentication to use (bitmask) */
902
#endif
903
  struct ssl_general_config general_ssl; /* general user defined SSL stuff */
904
  timediff_t dns_cache_timeout_ms; /* DNS cache timeout (milliseconds) */
905
  uint32_t buffer_size;        /* size of receive buffer to use */
906
  uint32_t upload_buffer_size; /* size of upload buffer to use, keep it >=
907
                                  CURL_MAX_WRITE_SIZE */
908
  void *private_data; /* application-private data */
909
#ifndef CURL_DISABLE_HTTP
910
  struct curl_slist *http200aliases; /* linked list of aliases for http200 */
911
#endif
912
  curl_off_t max_filesize; /* Maximum file size to download */
913
#ifndef CURL_DISABLE_FTP
914
  timediff_t accepttimeout;   /* in milliseconds, 0 means no timeout */
915
#endif
916
#if !defined(CURL_DISABLE_FTP) || defined(USE_SSH)
917
  struct curl_slist *quote;     /* after connection is established */
918
  struct curl_slist *postquote; /* after the transfer */
919
  struct curl_slist *prequote; /* before the transfer, after type */
920
#endif
921
#ifdef USE_LIBSSH2
922
  curl_sshhostkeycallback ssh_hostkeyfunc; /* hostkey check callback */
923
  void *ssh_hostkeyfunc_userp;         /* custom pointer to callback */
924
#endif
925
#ifdef USE_SSH
926
  curl_sshkeycallback ssh_keyfunc; /* key matching callback */
927
  void *ssh_keyfunc_userp;         /* custom pointer to callback */
928
  uint32_t ssh_auth_types;   /* allowed SSH auth types */
929
  uint32_t new_directory_perms; /* when creating remote dirs */
930
#endif
931
  struct u8_strset strings;
932
  struct curl_blob *blobs[BLOB_LAST];
933
  uint32_t new_file_perms;      /* when creating remote files */
934
#ifdef USE_IPV6
935
  uint32_t scope_id;  /* Scope id for IPv6 */
936
#endif
937
  curl_prot_t allowed_protocols;
938
  curl_prot_t redir_protocols;
939
#ifndef CURL_DISABLE_RTSP
940
  void *rtp_out;     /* write RTP to this if non-NULL */
941
#endif
942
#ifndef CURL_DISABLE_FTP
943
  curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer
944
                                        starts */
945
  curl_chunk_end_callback chunk_end; /* called after part transferring
946
                                        stopped */
947
  curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds
948
                                    to pattern (e.g. if WILDCARDMATCH is on) */
949
  void *fnmatch_data;
950
  void *wildcardptr;
951
#endif
952
953
  timediff_t timeout;   /* ms, 0 means no timeout */
954
  timediff_t connecttimeout; /* ms, 0 means default timeout */
955
  timediff_t happy_eyeballs_timeout; /* ms, 0 is a valid value */
956
  timediff_t server_response_timeout; /* ms, 0 means no timeout */
957
  timediff_t shutdowntimeout; /* ms, 0 means default timeout */
958
  curl_resolver_start_callback resolver_start; /* optional callback called
959
                                                  before resolver start */
960
  void *resolver_start_client; /* pointer to pass to resolver start callback */
961
  timediff_t upkeep_interval_ms; /* Time between calls for connection
962
                                    upkeep. */
963
  CURLU *uh; /* URL handle for the current parsed URL */
964
#ifndef CURL_DISABLE_HTTP
965
  void *trailer_data; /* pointer to pass to trailer data callback */
966
  curl_trailer_callback trailer_callback; /* trailing data callback */
967
#endif
968
#ifndef CURL_DISABLE_SMTP
969
  struct curl_slist *mail_rcpt; /* linked list of mail recipients */
970
#endif
971
  int tcp_keepidle;     /* seconds in idle before sending keepalive probe */
972
  int tcp_keepintvl;    /* seconds between TCP keepalive probes */
973
  int tcp_keepcnt;      /* maximum number of keepalive probes */
974
975
  uint32_t maxconnects; /* Max idle connections in the connection cache */
976
#if defined(USE_HTTP2) || defined(USE_HTTP3)
977
  /* Priority information for an easy handle in relation to others on the same
978
     connection. */
979
  int weight;
980
#endif
981
  short maxredirs;    /* maximum no. of http(s) redirects to follow,
982
                         set to -1 for infinity */
983
  uint16_t expect_100_timeout; /* in milliseconds */
984
  uint16_t use_port; /* which port to use (when not using default) */
985
  uint16_t low_speed_time;  /* number of seconds */
986
#ifndef CURL_DISABLE_BINDLOCAL
987
  uint16_t localport; /* local port number to bind to */
988
  uint16_t localportrange; /* number of additional port numbers to test
989
                                    in case the 'localport' one cannot be
990
                                    bind()ed */
991
#endif
992
#ifndef CURL_DISABLE_TFTP
993
  uint16_t tftp_blksize;    /* in bytes, 0 means use default */
994
#endif
995
#ifndef CURL_DISABLE_RTSP
996
  uint8_t rtspreq; /* RTSP request type */
997
#endif
998
#ifdef USE_ECH
999
  uint8_t tls_ech;      /* TLS ECH configuration */
1000
#endif
1001
#ifndef CURL_DISABLE_NETRC
1002
  uint8_t use_netrc;        /* enum CURL_NETRC_OPTION values */
1003
#endif
1004
#if !defined(CURL_DISABLE_FTP) || defined(USE_SSH)
1005
  /* Despite the name, ftp_create_missing_dirs is for FTP(S) and SFTP
1006
     1 - create directories that do not exist
1007
     2 - the same but also allow MKD to fail once
1008
   */
1009
  uint8_t ftp_create_missing_dirs;
1010
#endif
1011
#ifndef CURL_DISABLE_FTP
1012
  uint8_t ftp_filemethod; /* how to get to a file: curl_ftpfile */
1013
  uint8_t ftpsslauth; /* what AUTH XXX to try: curl_ftpauth */
1014
  uint8_t ftp_ccc;   /* FTP CCC options: curl_ftpccc */
1015
#endif
1016
  uint8_t httpsig_algorithm; /* CURLHTTPSIG_* algorithm for RFC 9421 */
1017
  uint8_t use_ssl;   /* if AUTH TLS is to be attempted etc, for FTP or IMAP or
1018
                        POP3 or others! (type: curl_usessl)*/
1019
  uint8_t timecondition; /* kind of time comparison: curl_TimeCond */
1020
  uint8_t method;   /* what kind of HTTP request: Curl_HttpReq */
1021
  uint8_t httpwant; /* when non-zero, a specific HTTP version requested
1022
                             to be used in the library's request(s) */
1023
  uint8_t ipver; /* the CURL_IPRESOLVE_* defines in the public header
1024
                          file 0 - whatever, 1 - v2, 2 - v6 */
1025
  uint8_t upload_flags; /* flags set by CURLOPT_UPLOAD_FLAGS */
1026
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
1027
  /* GSS-API/SSPI credential delegation, see CURLOPT_GSSAPI_DELEGATION */
1028
  uint8_t gssapi_delegation;
1029
#endif
1030
  uint8_t http_follow_mode; /* follow HTTP redirects */
1031
  BIT(connect_only); /* make connection/request, then let application use the
1032
                        socket */
1033
  BIT(connect_only_ws); /* special websocket connect-only level */
1034
#ifndef CURL_DISABLE_SMTP
1035
  BIT(mail_rcpt_allowfails); /* allow RCPT TO command to fail for some
1036
                                recipients */
1037
#endif
1038
#ifndef CURL_DISABLE_MIME
1039
  BIT(mime_formescape);
1040
#endif
1041
  BIT(is_fread_set); /* has read callback been set to non-NULL? */
1042
#ifndef CURL_DISABLE_TFTP
1043
  BIT(tftp_no_options); /* do not send TFTP options requests */
1044
#endif
1045
  BIT(sep_headers);     /* handle host and proxy headers separately */
1046
#ifndef CURL_DISABLE_COOKIES
1047
  BIT(cookiesession);   /* new cookie session? */
1048
#endif
1049
  BIT(crlf);            /* convert crlf on ftp upload(?) */
1050
#ifdef USE_SSH
1051
  BIT(ssh_compression);            /* enable SSH compression */
1052
#endif
1053
1054
/* Here follows boolean settings that define how to behave during
1055
   this session. They are STATIC, set by libcurl users or at least initially
1056
   and they do not change during operations. */
1057
  BIT(quick_exit);       /* set 1L when it is okay to leak things (like
1058
                            threads), as we are about to exit() anyway and
1059
                            do not want lengthy cleanups to delay termination,
1060
                            e.g. after a DNS timeout */
1061
  BIT(get_filetime);     /* get the time and get of the remote file */
1062
#ifndef CURL_DISABLE_PROXY
1063
  BIT(tunnel_thru_httpproxy); /* use CONNECT through an HTTP proxy */
1064
#endif
1065
  BIT(prefer_ascii);     /* ASCII rather than binary */
1066
  BIT(remote_append);    /* append, not overwrite, on upload */
1067
#ifdef CURL_LIST_ONLY_PROTOCOL
1068
  BIT(list_only);        /* list directory */
1069
#endif
1070
#ifndef CURL_DISABLE_FTP
1071
  BIT(ftp_use_port);     /* use the FTP PORT command */
1072
  BIT(ftp_use_epsv);     /* if EPSV is to be attempted or not */
1073
  BIT(ftp_use_eprt);     /* if EPRT is to be attempted or not */
1074
  BIT(ftp_use_pret);     /* if PRET is to be used before PASV or not */
1075
  BIT(ftp_skip_ip);      /* skip the IP address the FTP server passes on to
1076
                            us */
1077
  BIT(wildcard_enabled); /* enable wildcard matching */
1078
#endif
1079
  BIT(http_fail_on_error);  /* fail on HTTP error codes >= 400 */
1080
  BIT(http_keep_sending_on_error); /* for HTTP status codes >= 300 */
1081
  BIT(http_transfer_encoding); /* request compressed HTTP transfer-encoding */
1082
  BIT(allow_auth_to_other_hosts);
1083
  BIT(include_header); /* include received protocol headers in data output */
1084
  BIT(http_set_referer); /* is a custom referer used */
1085
  BIT(http_auto_referer); /* set "correct" referer when following
1086
                             location: */
1087
  BIT(opt_no_body);    /* as set with CURLOPT_NOBODY */
1088
  BIT(verbose);        /* output verbosity */
1089
  BIT(reuse_forbid);   /* forbidden to be reused, close after use */
1090
  BIT(reuse_fresh);    /* do not reuse an existing connection */
1091
  BIT(no_signal);      /* do not use any signal/alarm handler */
1092
  BIT(tcp_nodelay);    /* whether to enable TCP_NODELAY or not */
1093
  BIT(ignorecl);       /* ignore content length */
1094
  BIT(http_te_skip);   /* pass the raw body data to the user, even when
1095
                          transfer-encoded (chunked, compressed) */
1096
  BIT(http_ce_skip);   /* pass the raw body data to the user, even when
1097
                          content-encoded (chunked, compressed) */
1098
  BIT(proxy_transfer_mode); /* set transfer mode (;type=<a|i>) when doing
1099
                               FTP via an HTTP proxy */
1100
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
1101
  BIT(socks5_gssapi_nec); /* Flag to support NEC SOCKS5 server */
1102
#endif
1103
  BIT(sasl_ir);         /* Enable/disable SASL initial response */
1104
  BIT(tcp_keepalive);  /* use TCP keepalives */
1105
  BIT(tcp_fastopen);   /* use TCP Fast Open */
1106
  BIT(ssl_enable_alpn);/* TLS ALPN extension? */
1107
  BIT(path_as_is);     /* allow dotdots? */
1108
  BIT(pipewait);       /* wait for multiplex status before starting a new
1109
                          connection */
1110
  BIT(suppress_connect_headers); /* suppress proxy CONNECT response headers
1111
                                    from user callbacks */
1112
  BIT(dns_shuffle_addresses); /* whether to shuffle addresses before use */
1113
#ifndef CURL_DISABLE_PROXY
1114
  BIT(haproxyprotocol); /* whether to send HAProxy PROXY protocol v1
1115
                           header */
1116
#endif
1117
#ifdef USE_UNIX_SOCKETS
1118
  BIT(abstract_unix_socket);
1119
#endif
1120
  BIT(disallow_username_in_url); /* disallow username in URL */
1121
#ifndef CURL_DISABLE_DOH
1122
  BIT(doh); /* DNS-over-HTTPS enabled */
1123
  BIT(doh_verifypeer);     /* DoH certificate peer verification */
1124
  BIT(doh_verifyhost);     /* DoH certificate hostname verification */
1125
  BIT(doh_verifystatus);   /* DoH certificate status verification */
1126
#endif
1127
  BIT(http09_allowed); /* allow HTTP/0.9 responses */
1128
#ifndef CURL_DISABLE_WEBSOCKETS
1129
  BIT(ws_raw_mode);
1130
  BIT(ws_no_auto_pong);
1131
#endif
1132
  BIT(post301); /* keep POSTs as POSTs after a 301 request */
1133
  BIT(post302); /* keep POSTs as POSTs after a 302 request */
1134
  BIT(post303); /* keep POSTs as POSTs after a 303 request */
1135
};
1136
1137
#ifndef CURL_DISABLE_MIME
1138
#define IS_MIME_POST(a)                                                 \
1139
2.19k
  ((a)->set.mimepostp && ((a)->set.mimepostp->kind != MIMEKIND_NONE))
1140
#else
1141
#define IS_MIME_POST(a) FALSE
1142
#endif
1143
1144
/* callback that gets called when the transfer `data` is done and
1145
 * `data->master_mid` is set to an existing easy handle. */
1146
typedef void multi_sub_xfer_done_cb(struct Curl_easy *data,
1147
                                    struct Curl_easy *master,
1148
                                    CURLcode result);
1149
1150
/*
1151
 * The 'connectdata' struct MUST have all the connection oriented stuff as we
1152
 * may have several simultaneous connections and connection structs in memory.
1153
 *
1154
 * The 'struct UserDefined' must only contain data that is set once to go for
1155
 * many (perhaps) independent connections. Values that are generated or
1156
 * calculated internally for the "session handle" must be defined within the
1157
 * 'struct UrlState' instead.
1158
 */
1159
1160
struct Curl_easy {
1161
  /* First a simple identifier to more easily detect if a user mixes up this
1162
     easy handle with a multi handle. Set this to CURLEASY_MAGIC_NUMBER */
1163
  uint32_t magic;
1164
  /* once an easy handle is added to a multi, either explicitly by the
1165
   * libcurl application or implicitly during `curl_easy_perform()`,
1166
   * a unique identifier inside this one multi instance. */
1167
  uint32_t mid;
1168
  CURLMstate mstate;  /* the handle's state */
1169
  CURLcode result;   /* previous result */
1170
1171
  struct connectdata *conn;
1172
  struct Curl_multi *multi;    /* if non-NULL, points to the multi handle
1173
                                  struct to which this "belongs" when used by
1174
                                  the multi interface */
1175
  struct Curl_eapi_stack callstack; /* easy api calls ongoing */
1176
1177
  struct Curl_share *share;    /* Share, handles global variable mutexing */
1178
1179
  struct Curl_multi *multi_easy; /* if non-NULL, points to the multi handle
1180
                                    struct to which this "belongs" when used
1181
                                    by the easy interface */
1182
  struct CURLMsg msg; /* A single posted message. */
1183
1184
  /* once an easy handle is tied to a connection pool a non-negative number to
1185
     distinguish this transfer from other using the same pool. For easier
1186
     tracking in log output. This may wrap around after CURL_OFF_T_MAX to 0
1187
     again, so it has no uniqueness guarantee for large processings. Note: it
1188
     has no uniqueness either IFF more than one connection pool is used by the
1189
     libcurl application. */
1190
  curl_off_t id;
1191
  uint32_t master_mid; /* if set, this transfer belongs to a master */
1192
  multi_sub_xfer_done_cb *sub_xfer_done;
1193
1194
  /* `meta_hash` is a general key-value store for implementations
1195
   * with the lifetime of the easy handle.
1196
   * Elements need to be added with their own destructor to be invoked when
1197
   * the easy handle is cleaned up (see Curl_hash_add2()).*/
1198
  struct Curl_hash meta_hash;
1199
1200
#ifdef USE_LIBPSL
1201
  struct PslCache *psl;        /* The associated PSL cache. */
1202
#endif
1203
  struct SingleRequest req;    /* Request-specific data */
1204
  struct UserDefined set;      /* values set by the libcurl user */
1205
#ifndef CURL_DISABLE_COOKIES
1206
  struct CookieInfo *cookies;  /* the cookies, read from files and servers.
1207
                                  NOTE that the 'cookie' field in the
1208
                                  UserDefined struct defines if the "engine"
1209
                                  is to be used or not. */
1210
#endif
1211
#ifndef CURL_DISABLE_HSTS
1212
  struct hsts *hsts;
1213
#endif
1214
#ifndef CURL_DISABLE_ALTSVC
1215
  struct altsvcinfo *asi;      /* the alt-svc cache */
1216
#endif
1217
  struct Progress progress;    /* for all the progress meter data */
1218
  struct UrlState state;       /* struct for fields used for state info and
1219
                                  other dynamic purposes */
1220
#ifndef CURL_DISABLE_FTP
1221
  struct WildcardData *wildcard; /* wildcard download state info */
1222
#endif
1223
  struct PureInfo info;        /* stats, reports and info data */
1224
  struct curl_tlssessioninfo tsi; /* Information about the TLS session, only
1225
                                     valid after a client has asked for it */
1226
};
1227
1228
#define CURL_EASY_STR(d, id) \
1229
262k
  Curl_u8_strset_get(&(d)->set.strings, (uint8_t)(id))
1230
#define CURL_EASY_STR_SET(d, id, s, slen) \
1231
71.8k
  Curl_u8_strset_setx(&(d)->set.strings, (uint8_t)(id), (s), (slen))
1232
#define CURL_EASY_STR_SETN(d, id, s) \
1233
1.25k
  Curl_u8_strset_setn(&(d)->set.strings, (uint8_t)(id), (s))
1234
#define CURL_EASY_STR_CLEAR(d, id) \
1235
440
  Curl_u8_strset_unset(&(d)->set.strings, (uint8_t)(id))
1236
#define CURL_EASY_STR_CLEAR0(d, id) \
1237
118k
  Curl_u8_strset_unset0(&(d)->set.strings, (uint8_t)(id))
1238
1239
0
#define LIBCURL_NAME "libcurl"
1240
1241
#endif /* HEADER_CURL_URLDATA_H */