Coverage Report

Created: 2026-12-01 06:28

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