Coverage Report

Created: 2026-10-22 06:49

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