Coverage Report

Created: 2026-10-15 06:19

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
53.0k
#define DEFAULT_CONNCACHE_SIZE 5
39
40
/* length of longest IPv6 address string including the null-terminator */
41
28.4k
#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
564k
#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
53.0k
#define READBUFFER_SIZE CURL_MAX_WRITE_SIZE
121
1.37k
#define READBUFFER_MAX  CURL_MAX_READ_SIZE
122
1.37k
#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
53.0k
#define UPLOADBUFFER_DEFAULT 65536
133
1.36k
#define UPLOADBUFFER_MAX     (2 * 1024 * 1024)
134
1.36k
#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.25M
#define FIRSTSOCKET     0
232
416k
#define SECONDARYSOCKET 1
233
234
0
#define TRNSPRT_NONE 0
235
129k
#define TRNSPRT_TCP  3
236
32
#define TRNSPRT_UDP  4
237
32
#define TRNSPRT_QUIC 5
238
29.6k
#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
50
  (((x)->transport == TRNSPRT_TCP) || \
252
50
   ((x)->transport == TRNSPRT_UDP) || \
253
50
   ((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
1.08M
#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
134k
#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
348k
#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
#ifdef USE_OPENSSL
560
  /* void instead of ENGINE to avoid bleeding OpenSSL into this header */
561
  void *engine;
562
  /* void instead of OSSL_PROVIDER */
563
  void *provider;
564
  void *baseprov;
565
  void *libctx;
566
  char *propq; /* for a provider */
567
#endif /* USE_OPENSSL */
568
  struct expire_timers timeouts; /* expire timeouts */
569
570
  /* a place to store the most recently set (S)FTP entrypath */
571
  char *most_recent_ftp_entrypath;
572
  char *range; /* range, if used. See README for detailed specification on
573
                  this syntax. */
574
  curl_off_t resume_from; /* continue [ftp] transfer from here */
575
  curl_off_t infilesize; /* size of file to upload, -1 means unknown.
576
                            Copied from set.filesize at start of operation */
577
  curl_read_callback fread_func; /* read callback/function */
578
  void *in;                      /* CURLOPT_READDATA */
579
  CURLU *uh; /* URL handle for the current parsed URL */
580
  struct urlpieces up;
581
  struct bufref url;        /* work URL, initially copied from UserDefined */
582
  struct bufref referer;    /* referer string */
583
  struct curl_slist *resolve; /* set to point to the set.resolve list when
584
                                 this should be dealt with in pretransfer */
585
#ifndef CURL_DISABLE_HTTP
586
  curl_mimepart *mimepost;
587
#ifndef CURL_DISABLE_FORM_API
588
  curl_mimepart *formp; /* storage for old API form-posting, allocated on
589
                           demand */
590
#endif
591
  struct Curl_llist httphdrs; /* received headers */
592
  struct curl_header headerout[2]; /* for external purposes */
593
  /* curl_easy_nextheader() cache parameters */
594
  unsigned int nh_origin;
595
  int nh_request;
596
  size_t nh_count; /* httphdrs count when the cache was filled */
597
#endif
598
#ifndef CURL_DISABLE_COOKIES
599
  struct curl_slist *cookielist; /* list of cookie files set by
600
                                    curl_easy_setopt(COOKIEFILE) calls */
601
#endif
602
603
#ifdef CURLVERBOSE
604
  struct curl_trc_feat *feat; /* opt. trace feature transfer is part of */
605
#endif
606
607
#ifndef CURL_DISABLE_NETRC
608
  struct store_netrc netrc;
609
#endif
610
611
  struct Curl_creds *creds; /* Credentials for the origin only */
612
613
#ifndef CURL_DISABLE_HTTP
614
  char *rangeline; /* allocated */
615
  char *http_host; /* allocated */
616
  struct http_negotiation http_neg;
617
#endif
618
#ifndef CURL_DISABLE_RTSP
619
  /* This RTSP state information survives requests and connections */
620
  struct Curl_peer *rtsp_session_origin; /* origin that issued the session id,
621
                                            NULL when set by the application */
622
  uint8_t rtp_channel_mask[32]; /* for the correctness checking of the
623
                                         interleaved data */
624
  uint32_t rtsp_next_client_CSeq; /* the session's next client CSeq */
625
  uint32_t rtsp_next_server_CSeq; /* the session's next server CSeq */
626
  uint32_t rtsp_CSeq_recv; /* most recent CSeq received */
627
#endif
628
629
  curl_off_t last_conn_id; /* The last assigned connection or -1 */
630
  uint32_t last_cpid; /* last connection pool id used */
631
632
#if defined(USE_HTTP2) || defined(USE_HTTP3)
633
  int weight; /* shallow copy of data->set */
634
#endif
635
  uint16_t followlocation; /* redirect counter */
636
  uint8_t retrycount; /* number of retries on a new connection, up to
637
                               CONN_MAX_RETRIES */
638
  uint8_t httpreq; /* Curl_HttpReq; what kind of HTTP request (if any)
639
                            is this */
640
641
#ifdef USE_OPENSSL
642
  BIT(provider_loaded);
643
#endif /* USE_OPENSSL */
644
  BIT(really_alive); /* transfer is really alive in multi, passed INIT */
645
  BIT(this_is_a_follow); /* this is a followed Location: request */
646
  BIT(refused_stream); /* this was refused, try again */
647
  BIT(errorbuf); /* Set to TRUE if the error buffer is already filled in.
648
                    This must be set to FALSE every time _easy_perform() is
649
                    called. */
650
  BIT(allow_port); /* Is set.use_port allowed to take effect or not. This
651
                      is always set TRUE when curl_easy_perform() is called. */
652
  BIT(authproblem); /* TRUE if there is some problem authenticating */
653
  /* set after initial USER failure, to prevent an authentication loop */
654
  BIT(wildcardmatch); /* enable wildcard matching */
655
  BIT(disableexpect);    /* TRUE if Expect: is disabled due to a previous
656
                            417 response */
657
  BIT(use_range);
658
  BIT(rangestringalloc); /* the range string is malloc()'ed */
659
  BIT(done); /* set to FALSE when Curl_init_transfer() is called and set to
660
                TRUE when multi_done() is called, to prevent multi_done() from
661
                being invoked twice. */
662
#ifndef CURL_DISABLE_COOKIES
663
  BIT(cookie_engine);
664
#endif
665
  BIT(prefer_ascii);   /* ASCII rather than binary */
666
#ifdef CURL_LIST_ONLY_PROTOCOL
667
  BIT(list_only);      /* list directory contents */
668
#endif
669
  BIT(wildcard_resolve); /* Set to true if any resolve change is a wildcard */
670
  BIT(upload);         /* upload request */
671
  BIT(internal); /* internal: true if this easy handle was created for
672
                    internal use and the user does not have ownership of the
673
                    handle. */
674
  BIT(http_ignorecustom); /* ignore custom method from now */
675
#ifndef CURL_DISABLE_HTTP
676
  BIT(http_hd_te); /* Added HTTP header TE: */
677
  BIT(http_hd_upgrade); /* Added HTTP header Upgrade: */
678
  BIT(http_hd_h2_settings); /* Added HTTP header H2Settings: */
679
  BIT(maybe_folded);
680
  BIT(leading_unfold); /* unfold started, this is the leading bytes */
681
#endif
682
};
683
684
/*
685
 * This 'UserDefined' struct must only contain data that is set once to go
686
 * for many (perhaps) independent connections. Values that are generated or
687
 * calculated internally for the "session handle" MUST be defined within the
688
 * 'struct UrlState' instead. The only exceptions MUST note the changes in
689
 * the 'DynamicStatic' struct.
690
 * Character pointer fields point to dynamic storage, unless otherwise stated.
691
 */
692
693
struct Curl_multi;    /* declared in multihandle.c */
694
695
enum dupstring {
696
  STRING_CERT,            /* client certificate filename */
697
  STRING_CERT_TYPE,       /* format for certificate (default: PEM)*/
698
  STRING_KEY,             /* private key filename */
699
  STRING_KEY_PASSWD,      /* plain text private key password */
700
  STRING_KEY_TYPE,        /* format for private key (default: PEM) */
701
  STRING_SSL_CAPATH,      /* CA directory name (does not work on Windows) */
702
  STRING_SSL_CAFILE,      /* certificate file to verify peer against */
703
  STRING_SSL_PINNEDPUBLICKEY, /* public key file to verify peer against */
704
  STRING_SSL_CIPHER_LIST, /* list of ciphers to use */
705
  STRING_SSL_CIPHER13_LIST, /* list of TLS 1.3 ciphers to use */
706
  STRING_SSL_CRLFILE,     /* CRL file to check certificate */
707
  STRING_SSL_ISSUERCERT,  /* issuer cert file to check certificate */
708
  STRING_SERVICE_NAME,    /* Service name */
709
#ifndef CURL_DISABLE_PROXY
710
  STRING_CERT_PROXY,      /* client certificate filename */
711
  STRING_CERT_TYPE_PROXY, /* format for certificate (default: PEM)*/
712
  STRING_KEY_PROXY,       /* private key filename */
713
  STRING_KEY_PASSWD_PROXY, /* plain text private key password */
714
  STRING_KEY_TYPE_PROXY,  /* format for private key (default: PEM) */
715
  STRING_SSL_CAPATH_PROXY, /* CA directory name (does not work on Windows) */
716
  STRING_SSL_CAFILE_PROXY, /* certificate file to verify peer against */
717
  STRING_SSL_PINNEDPUBLICKEY_PROXY, /* public key file to verify proxy */
718
  STRING_SSL_CIPHER_LIST_PROXY, /* list of ciphers to use */
719
  STRING_SSL_CIPHER13_LIST_PROXY, /* list of TLS 1.3 ciphers to use */
720
  STRING_SSL_CRLFILE_PROXY, /* CRL file to check certificate */
721
  STRING_SSL_ISSUERCERT_PROXY, /* issuer cert file to check certificate */
722
  STRING_PROXY_SERVICE_NAME, /* Proxy service name */
723
#endif
724
#ifndef CURL_DISABLE_COOKIES
725
  STRING_COOKIE,          /* HTTP cookie string to send */
726
  STRING_COOKIEJAR,       /* dump all cookies to this file */
727
#endif
728
  STRING_CUSTOMREQUEST,   /* HTTP/FTP/RTSP request/method to use */
729
  STRING_DEFAULT_PROTOCOL, /* Protocol to use when the URL does not specify */
730
  STRING_INTERFACE_OPT,   /* CURLOPT_INTERFACE config */
731
  STRING_ENCODING,        /* Accept-Encoding string */
732
#ifndef CURL_DISABLE_FTP
733
  STRING_FTP_ACCOUNT,     /* ftp account data */
734
  STRING_FTP_ALTERNATIVE_TO_USER, /* command to send if USER/PASS fails */
735
  STRING_FTPPORT,         /* port to send with the FTP PORT command */
736
#endif
737
#ifndef CURL_DISABLE_NETRC
738
  STRING_NETRC_FILE,      /* if not NULL, use this instead of trying to find
739
                             $HOME/.netrc */
740
#endif
741
#ifndef CURL_DISABLE_PROXY
742
  STRING_PROXY,           /* proxy to use */
743
  STRING_PRE_PROXY,       /* pre socks proxy to use */
744
#endif
745
  STRING_SET_RANGE,       /* range, if used */
746
  STRING_SET_REFERER,     /* custom string for the HTTP referer field */
747
  STRING_SET_URL,         /* what original URL to work on */
748
  STRING_USERAGENT,       /* User-Agent string */
749
  STRING_SSL_ENGINE,      /* name of SSL engine */
750
  STRING_USERNAME,        /* <username>, if used */
751
  STRING_PASSWORD,        /* <password>, if used */
752
  STRING_OPTIONS,         /* <options>, if used */
753
#ifndef CURL_DISABLE_PROXY
754
  STRING_PROXYUSERNAME,   /* Proxy <username>, if used */
755
  STRING_PROXYPASSWORD,   /* Proxy <password>, if used */
756
  STRING_NOPROXY,         /* List of hosts which should not use the proxy, if
757
                             used */
758
#endif
759
#ifndef CURL_DISABLE_RTSP
760
  STRING_RTSP_SESSION_ID, /* Session ID to use */
761
  STRING_RTSP_STREAM_URI, /* Stream URI for this request */
762
  STRING_RTSP_TRANSPORT,  /* Transport for this session */
763
#endif
764
#ifdef USE_SSH
765
  STRING_SSH_PRIVATE_KEY, /* path to the private key file for auth */
766
  STRING_SSH_PUBLIC_KEY,  /* path to the public key file for auth */
767
  STRING_SSH_HOST_PUBLIC_KEY_MD5, /* md5 of host public key in ASCII hex */
768
  STRING_SSH_HOST_PUBLIC_KEY_SHA256, /* sha256 of host public key in base64 */
769
  STRING_SSH_KNOWNHOSTS,  /* filename of knownhosts file */
770
#endif
771
#ifndef CURL_DISABLE_SMTP
772
  STRING_MAIL_FROM,
773
  STRING_MAIL_AUTH,
774
#endif
775
  STRING_BEARER,                /* <bearer>, if used */
776
#ifdef USE_UNIX_SOCKETS
777
  STRING_UNIX_SOCKET_PATH,      /* path to Unix socket, if used */
778
#endif
779
  STRING_TARGET,                /* CURLOPT_REQUEST_TARGET */
780
#ifndef CURL_DISABLE_DOH
781
  STRING_DOH,                   /* CURLOPT_DOH_URL */
782
#endif
783
#ifndef CURL_DISABLE_ALTSVC
784
  STRING_ALTSVC,                /* CURLOPT_ALTSVC */
785
#endif
786
#ifndef CURL_DISABLE_HSTS
787
  STRING_HSTS,                  /* CURLOPT_HSTS */
788
#endif
789
  STRING_SASL_AUTHZID,          /* CURLOPT_SASL_AUTHZID */
790
#ifdef USE_ARES
791
  STRING_DNS_SERVERS,
792
  STRING_DNS_INTERFACE,
793
  STRING_DNS_LOCAL_IP4,
794
  STRING_DNS_LOCAL_IP6,
795
#endif
796
  STRING_SSL_EC_CURVES,
797
#ifndef CURL_DISABLE_AWS
798
  STRING_AWS_SIGV4, /* Parameters for V4 signature */
799
#endif
800
#ifndef CURL_DISABLE_HTTPSIG
801
  STRING_HTTPSIG_KEY,    /* hex-encoded key data */
802
  STRING_HTTPSIG_KEYID,  /* key identifier */
803
  STRING_HTTPSIG_HEADERS, /* space-separated components to sign */
804
#endif
805
#ifndef CURL_DISABLE_PROXY
806
  STRING_HAPROXY_CLIENT_IP,     /* CURLOPT_HAPROXY_CLIENT_IP */
807
#endif
808
  STRING_ECH_CONFIG,            /* CURLOPT_ECH_CONFIG */
809
  STRING_ECH_PUBLIC,            /* CURLOPT_ECH_PUBLIC */
810
  STRING_SSL_SIGNATURE_ALGORITHMS, /* CURLOPT_SSL_SIGNATURE_ALGORITHMS */
811
812
  STRING_LAST /* not used, an end-of-list marker */
813
};
814
815
enum dupblob {
816
  BLOB_CERT,
817
  BLOB_KEY,
818
  BLOB_SSL_ISSUERCERT,
819
  BLOB_CAINFO,
820
#ifndef CURL_DISABLE_PROXY
821
  BLOB_CERT_PROXY,
822
  BLOB_KEY_PROXY,
823
  BLOB_SSL_ISSUERCERT_PROXY,
824
  BLOB_CAINFO_PROXY,
825
#endif
826
  BLOB_LAST
827
};
828
829
struct UserDefined {
830
  FILE *err;         /* the stderr user data goes here */
831
  void *debugdata;   /* the data that will be passed to fdebug */
832
  char *errorbuffer; /* (Static) store failure messages in here */
833
  void *out;         /* CURLOPT_WRITEDATA */
834
  void *in_set;      /* CURLOPT_READDATA */
835
  void *writeheader; /* write the header to this if non-NULL */
836
  uint32_t httpauth;  /* kind of HTTP authentication to use (bitmask) */
837
  uint32_t proxyauth; /* kind of proxy authentication to use (bitmask) */
838
  void *postfields;  /* if POST, set the fields' values here */
839
  char *str_copypostfields; /* CURLOPT_COPYPOSTFIELDS value */
840
  curl_seek_callback seek_func;      /* function that seeks the input */
841
  curl_off_t postfieldsize; /* if POST, this might have a size to use instead
842
                               of strlen(), and then the data *may* be binary
843
                               (contain NUL bytes) */
844
  curl_write_callback fwrite_func;   /* function that stores the output */
845
  curl_write_callback fwrite_header; /* function that stores headers */
846
  curl_write_callback fwrite_rtp;    /* function that stores interleaved RTP */
847
  curl_read_callback fread_func_set; /* function that reads the input */
848
  curl_progress_callback fprogress; /* OLD and deprecated progress callback */
849
  curl_xferinfo_callback fxferinfo; /* progress callback */
850
  curl_debug_callback fdebug;      /* function that write informational data */
851
  curl_ioctl_callback ioctl_func;  /* function for I/O control */
852
  curl_sockopt_callback fsockopt;  /* function for setting socket options */
853
  void *sockopt_client; /* pointer to pass to the socket options callback */
854
  curl_opensocket_callback fopensocket; /* function for checking/translating
855
                                           the address and opening the
856
                                           socket */
857
  void *opensocket_client;
858
  curl_closesocket_callback fclosesocket; /* function for closing the
859
                                             socket */
860
  void *closesocket_client;
861
  curl_prereq_callback fprereq; /* pre-initial request callback */
862
  void *prereq_userp; /* pre-initial request user data */
863
864
  void *seek_client;    /* pointer to pass to the seek callback */
865
#ifndef CURL_DISABLE_HSTS
866
  curl_hstsread_callback hsts_read;
867
  void *hsts_read_userp;
868
  curl_hstswrite_callback hsts_write;
869
  void *hsts_write_userp;
870
#endif
871
  void *progress_client; /* pointer to pass to the progress callback */
872
  void *ioctl_client;   /* pointer to pass to the ioctl callback */
873
  timediff_t conn_max_idle_ms; /* max idle time to allow a connection that
874
                                  is to be reused */
875
  timediff_t conn_max_age_ms; /* max time since creation to allow a
876
                                 connection that is to be reused */
877
  curl_off_t filesize;  /* size of file to upload, -1 means unknown */
878
  curl_off_t low_speed_limit; /* bytes/second */
879
  curl_off_t max_send_speed; /* high speed limit in bytes/second for upload */
880
  curl_off_t max_recv_speed; /* high speed limit in bytes/second for
881
                                download */
882
  curl_off_t set_resume_from;  /* continue [ftp] transfer from here */
883
  struct curl_slist *headers; /* linked list of extra headers */
884
  struct curl_httppost *httppost;  /* linked list of old POST data */
885
#if !defined(CURL_DISABLE_MIME) || !defined(CURL_DISABLE_FORM_API)
886
  curl_mimepart *mimepostp;  /* MIME/POST data. */
887
#endif
888
#ifndef CURL_DISABLE_TELNET
889
  struct curl_slist *telnet_options; /* linked list of telnet options */
890
#endif
891
  struct curl_slist *resolve;     /* list of names to add/remove from
892
                                     DNS cache */
893
  struct curl_slist *connect_to; /* list of host:port mappings to override
894
                                    the hostname and port to connect to */
895
  time_t timevalue;       /* what time to compare with */
896
  struct ssl_easy_config ssl;  /* user defined SSL stuff */
897
  curl_ssl_ctx_callback ssl_fsslctx; /* function to initialize SSL ctx */
898
  void *ssl_fsslctxp;        /* parameter for callback */
899
#ifndef CURL_DISABLE_PROXY
900
  struct ssl_easy_config proxy_ssl;  /* user defined SSL stuff for proxy */
901
  struct curl_slist *proxyheaders; /* linked list of extra CONNECT headers */
902
  uint16_t proxyport;       /* If non-zero, use this port number by
903
                               default. If the proxy string features a
904
                               ":[port]" that one will override this. */
905
  uint8_t proxytype; /* what kind of proxy */
906
  uint8_t socks5auth;/* kind of SOCKS5 authentication to use (bitmask) */
907
#endif
908
  timediff_t dns_cache_timeout_ms; /* DNS cache timeout (milliseconds) */
909
  uint32_t buffer_size;        /* size of receive buffer to use */
910
  uint32_t upload_buffer_size; /* size of upload buffer to use, keep it >=
911
                                  CURL_MAX_WRITE_SIZE */
912
  void *private_data; /* application-private data */
913
#ifndef CURL_DISABLE_HTTP
914
  struct curl_slist *http200aliases; /* linked list of aliases for http200 */
915
#endif
916
  curl_off_t max_filesize; /* Maximum file size to download */
917
#ifndef CURL_DISABLE_FTP
918
  timediff_t accepttimeout;   /* in milliseconds, 0 means no timeout */
919
#endif
920
#if !defined(CURL_DISABLE_FTP) || defined(USE_SSH)
921
  struct curl_slist *quote;     /* after connection is established */
922
  struct curl_slist *postquote; /* after the transfer */
923
  struct curl_slist *prequote; /* before the transfer, after type */
924
#endif
925
#ifdef USE_LIBSSH2
926
  curl_sshhostkeycallback ssh_hostkeyfunc; /* hostkey check callback */
927
  void *ssh_hostkeyfunc_userp;         /* custom pointer to callback */
928
#endif
929
#ifdef USE_SSH
930
  curl_sshkeycallback ssh_keyfunc; /* key matching callback */
931
  void *ssh_keyfunc_userp;         /* custom pointer to callback */
932
  uint32_t ssh_auth_types;   /* allowed SSH auth types */
933
  uint32_t new_directory_perms; /* when creating remote dirs */
934
#endif
935
  struct u8_strset strings;
936
  struct curl_blob *blobs[BLOB_LAST];
937
  uint32_t new_file_perms;      /* when creating remote files */
938
#ifdef USE_IPV6
939
  uint32_t scope_id;  /* Scope id for IPv6 */
940
#endif
941
  curl_prot_t allowed_protocols;
942
  curl_prot_t redir_protocols;
943
#ifndef CURL_DISABLE_RTSP
944
  void *rtp_out;     /* write RTP to this if non-NULL */
945
#endif
946
#ifndef CURL_DISABLE_FTP
947
  curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer
948
                                        starts */
949
  curl_chunk_end_callback chunk_end; /* called after part transferring
950
                                        stopped */
951
  curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds
952
                                    to pattern (e.g. if WILDCARDMATCH is on) */
953
  void *fnmatch_data;
954
  void *wildcardptr;
955
#endif
956
957
  timediff_t timeout;   /* ms, 0 means no timeout */
958
  timediff_t connecttimeout; /* ms, 0 means default timeout */
959
  timediff_t happy_eyeballs_timeout; /* ms, 0 is a valid value */
960
  timediff_t server_response_timeout; /* ms, 0 means no timeout */
961
  timediff_t shutdowntimeout; /* ms, 0 means default timeout */
962
  curl_resolver_start_callback resolver_start; /* optional callback called
963
                                                  before resolver start */
964
  void *resolver_start_client; /* pointer to pass to resolver start callback */
965
  timediff_t upkeep_interval_ms; /* Time between calls for connection
966
                                    upkeep. */
967
  CURLU *uh; /* URL handle for the current parsed URL */
968
#ifndef CURL_DISABLE_HTTP
969
  void *trailer_data; /* pointer to pass to trailer data callback */
970
  curl_trailer_callback trailer_callback; /* trailing data callback */
971
#endif
972
#ifndef CURL_DISABLE_SMTP
973
  struct curl_slist *mail_rcpt; /* linked list of mail recipients */
974
#endif
975
  int ssl_ca_cache_timeout;  /* Certificate store cache timeout (seconds) */
976
977
  int tcp_keepidle;     /* seconds in idle before sending keepalive probe */
978
  int tcp_keepintvl;    /* seconds between TCP keepalive probes */
979
  int tcp_keepcnt;      /* maximum number of keepalive probes */
980
981
  uint32_t maxconnects; /* Max idle connections in the connection cache */
982
#if defined(USE_HTTP2) || defined(USE_HTTP3)
983
  /* Priority information for an easy handle in relation to others on the same
984
     connection. */
985
  int weight;
986
#endif
987
  short maxredirs;    /* maximum no. of http(s) redirects to follow,
988
                         set to -1 for infinity */
989
  uint16_t expect_100_timeout; /* in milliseconds */
990
  uint16_t use_port; /* which port to use (when not using default) */
991
  uint16_t low_speed_time;  /* number of seconds */
992
#ifndef CURL_DISABLE_BINDLOCAL
993
  uint16_t localport; /* local port number to bind to */
994
  uint16_t localportrange; /* number of additional port numbers to test
995
                                    in case the 'localport' one cannot be
996
                                    bind()ed */
997
#endif
998
#ifndef CURL_DISABLE_TFTP
999
  uint16_t tftp_blksize;    /* in bytes, 0 means use default */
1000
#endif
1001
#ifndef CURL_DISABLE_RTSP
1002
  uint8_t rtspreq; /* RTSP request type */
1003
#endif
1004
#ifndef CURL_DISABLE_NETRC
1005
  uint8_t use_netrc;        /* enum CURL_NETRC_OPTION values */
1006
#endif
1007
#if !defined(CURL_DISABLE_FTP) || defined(USE_SSH)
1008
  /* Despite the name, ftp_create_missing_dirs is for FTP(S) and SFTP
1009
     1 - create directories that do not exist
1010
     2 - the same but also allow MKD to fail once
1011
   */
1012
  uint8_t ftp_create_missing_dirs;
1013
#endif
1014
#ifndef CURL_DISABLE_FTP
1015
  uint8_t ftp_filemethod; /* how to get to a file: curl_ftpfile */
1016
  uint8_t ftpsslauth; /* what AUTH XXX to try: curl_ftpauth */
1017
  uint8_t ftp_ccc;   /* FTP CCC options: curl_ftpccc */
1018
#endif
1019
  uint8_t httpsig_algorithm; /* CURLHTTPSIG_* algorithm for RFC 9421 */
1020
  uint8_t use_ssl;   /* if AUTH TLS is to be attempted etc, for FTP or IMAP or
1021
                        POP3 or others! (type: curl_usessl)*/
1022
  uint8_t timecondition; /* kind of time comparison: curl_TimeCond */
1023
  uint8_t method;   /* what kind of HTTP request: Curl_HttpReq */
1024
  uint8_t httpwant; /* when non-zero, a specific HTTP version requested
1025
                             to be used in the library's request(s) */
1026
  uint8_t ipver; /* the CURL_IPRESOLVE_* defines in the public header
1027
                          file 0 - whatever, 1 - v2, 2 - v6 */
1028
  uint8_t upload_flags; /* flags set by CURLOPT_UPLOAD_FLAGS */
1029
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
1030
  /* GSS-API/SSPI credential delegation, see CURLOPT_GSSAPI_DELEGATION */
1031
  uint8_t gssapi_delegation;
1032
#endif
1033
  uint8_t http_follow_mode; /* follow HTTP redirects */
1034
  BIT(connect_only); /* make connection/request, then let application use the
1035
                        socket */
1036
  BIT(connect_only_ws); /* special websocket connect-only level */
1037
#ifndef CURL_DISABLE_SMTP
1038
  BIT(mail_rcpt_allowfails); /* allow RCPT TO command to fail for some
1039
                                recipients */
1040
#endif
1041
#ifndef CURL_DISABLE_MIME
1042
  BIT(mime_formescape);
1043
#endif
1044
  BIT(is_fread_set); /* has read callback been set to non-NULL? */
1045
#ifndef CURL_DISABLE_TFTP
1046
  BIT(tftp_no_options); /* do not send TFTP options requests */
1047
#endif
1048
  BIT(sep_headers);     /* handle host and proxy headers separately */
1049
#ifndef CURL_DISABLE_COOKIES
1050
  BIT(cookiesession);   /* new cookie session? */
1051
#endif
1052
  BIT(crlf);            /* convert crlf on ftp upload(?) */
1053
#ifdef USE_SSH
1054
  BIT(ssh_compression);            /* enable SSH compression */
1055
#endif
1056
1057
/* Here follows boolean settings that define how to behave during
1058
   this session. They are STATIC, set by libcurl users or at least initially
1059
   and they do not change during operations. */
1060
  BIT(quick_exit);       /* set 1L when it is okay to leak things (like
1061
                            threads), as we are about to exit() anyway and
1062
                            do not want lengthy cleanups to delay termination,
1063
                            e.g. after a DNS timeout */
1064
  BIT(get_filetime);     /* get the time and get of the remote file */
1065
#ifndef CURL_DISABLE_PROXY
1066
  BIT(tunnel_thru_httpproxy); /* use CONNECT through an HTTP proxy */
1067
#endif
1068
  BIT(prefer_ascii);     /* ASCII rather than binary */
1069
  BIT(remote_append);    /* append, not overwrite, on upload */
1070
#ifdef CURL_LIST_ONLY_PROTOCOL
1071
  BIT(list_only);        /* list directory */
1072
#endif
1073
#ifndef CURL_DISABLE_FTP
1074
  BIT(ftp_use_port);     /* use the FTP PORT command */
1075
  BIT(ftp_use_epsv);     /* if EPSV is to be attempted or not */
1076
  BIT(ftp_use_eprt);     /* if EPRT is to be attempted or not */
1077
  BIT(ftp_use_pret);     /* if PRET is to be used before PASV or not */
1078
  BIT(ftp_skip_ip);      /* skip the IP address the FTP server passes on to
1079
                            us */
1080
  BIT(wildcard_enabled); /* enable wildcard matching */
1081
#endif
1082
  BIT(http_fail_on_error);  /* fail on HTTP error codes >= 400 */
1083
  BIT(http_keep_sending_on_error); /* for HTTP status codes >= 300 */
1084
  BIT(http_transfer_encoding); /* request compressed HTTP transfer-encoding */
1085
  BIT(allow_auth_to_other_hosts);
1086
  BIT(include_header); /* include received protocol headers in data output */
1087
  BIT(http_set_referer); /* is a custom referer used */
1088
  BIT(http_auto_referer); /* set "correct" referer when following
1089
                             location: */
1090
  BIT(opt_no_body);    /* as set with CURLOPT_NOBODY */
1091
  BIT(verbose);        /* output verbosity */
1092
  BIT(reuse_forbid);   /* forbidden to be reused, close after use */
1093
  BIT(reuse_fresh);    /* do not reuse an existing connection */
1094
  BIT(no_signal);      /* do not use any signal/alarm handler */
1095
  BIT(tcp_nodelay);    /* whether to enable TCP_NODELAY or not */
1096
  BIT(ignorecl);       /* ignore content length */
1097
  BIT(http_te_skip);   /* pass the raw body data to the user, even when
1098
                          transfer-encoded (chunked, compressed) */
1099
  BIT(http_ce_skip);   /* pass the raw body data to the user, even when
1100
                          content-encoded (chunked, compressed) */
1101
  BIT(proxy_transfer_mode); /* set transfer mode (;type=<a|i>) when doing
1102
                               FTP via an HTTP proxy */
1103
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
1104
  BIT(socks5_gssapi_nec); /* Flag to support NEC SOCKS5 server */
1105
#endif
1106
  BIT(socks5_auth_only); /* SOCKS5 must authenticate */
1107
  BIT(sasl_ir);         /* Enable/disable SASL initial response */
1108
  BIT(tcp_keepalive);  /* use TCP keepalives */
1109
  BIT(tcp_fastopen);   /* use TCP Fast Open */
1110
  BIT(ssl_enable_alpn);/* TLS ALPN extension? */
1111
  BIT(path_as_is);     /* allow dotdots? */
1112
  BIT(pipewait);       /* wait for multiplex status before starting a new
1113
                          connection */
1114
  BIT(suppress_connect_headers); /* suppress proxy CONNECT response headers
1115
                                    from user callbacks */
1116
  BIT(dns_shuffle_addresses); /* whether to shuffle addresses before use */
1117
#ifndef CURL_DISABLE_PROXY
1118
  BIT(haproxyprotocol); /* whether to send HAProxy PROXY protocol v1
1119
                           header */
1120
#endif
1121
#ifdef USE_UNIX_SOCKETS
1122
  BIT(abstract_unix_socket);
1123
#endif
1124
  BIT(disallow_username_in_url); /* disallow username in URL */
1125
#ifndef CURL_DISABLE_DOH
1126
  BIT(doh); /* DNS-over-HTTPS enabled */
1127
  BIT(doh_verifypeer);     /* DoH certificate peer verification */
1128
  BIT(doh_verifyhost);     /* DoH certificate hostname verification */
1129
  BIT(doh_verifystatus);   /* DoH certificate status verification */
1130
#endif
1131
  BIT(http09_allowed); /* allow HTTP/0.9 responses */
1132
#ifndef CURL_DISABLE_WEBSOCKETS
1133
  BIT(ws_raw_mode);
1134
  BIT(ws_no_auto_pong);
1135
#endif
1136
  BIT(post301); /* keep POSTs as POSTs after a 301 request */
1137
  BIT(post302); /* keep POSTs as POSTs after a 302 request */
1138
  BIT(post303); /* keep POSTs as POSTs after a 303 request */
1139
};
1140
1141
#ifndef CURL_DISABLE_MIME
1142
#define IS_MIME_POST(a)                                                 \
1143
0
  ((a)->set.mimepostp && ((a)->set.mimepostp->kind != MIMEKIND_NONE))
1144
#else
1145
#define IS_MIME_POST(a) FALSE
1146
#endif
1147
1148
/* callback that gets called when the transfer `data` is done and
1149
 * `data->master_mid` is set to an existing easy handle. */
1150
typedef void multi_sub_xfer_done_cb(struct Curl_easy *data,
1151
                                    struct Curl_easy *master,
1152
                                    CURLcode result);
1153
1154
/*
1155
 * The 'connectdata' struct MUST have all the connection oriented stuff as we
1156
 * may have several simultaneous connections and connection structs in memory.
1157
 *
1158
 * The 'struct UserDefined' must only contain data that is set once to go for
1159
 * many (perhaps) independent connections. Values that are generated or
1160
 * calculated internally for the "session handle" must be defined within the
1161
 * 'struct UrlState' instead.
1162
 */
1163
1164
struct Curl_easy {
1165
  /* First a simple identifier to more easily detect if a user mixes up this
1166
     easy handle with a multi handle. Set this to CURLEASY_MAGIC_NUMBER */
1167
  uint32_t magic;
1168
  /* once an easy handle is added to a multi, either explicitly by the
1169
   * libcurl application or implicitly during `curl_easy_perform()`,
1170
   * a unique identifier inside this one multi instance. */
1171
  uint32_t mid;
1172
  CURLMstate mstate;  /* the handle's state */
1173
  CURLcode result;   /* previous result */
1174
1175
  struct connectdata *conn;
1176
  struct Curl_multi *multi;    /* if non-NULL, points to the multi handle
1177
                                  struct to which this "belongs" when used by
1178
                                  the multi interface */
1179
  struct Curl_eapi_stack callstack; /* easy api calls ongoing */
1180
1181
  struct Curl_share *share;    /* Share, handles global variable mutexing */
1182
1183
  struct Curl_multi *multi_easy; /* if non-NULL, points to the multi handle
1184
                                    struct to which this "belongs" when used
1185
                                    by the easy interface */
1186
  struct CURLMsg msg; /* A single posted message. */
1187
1188
  /* once an easy handle is tied to a connection pool a non-negative number to
1189
     distinguish this transfer from other using the same pool. For easier
1190
     tracking in log output. This may wrap around after CURL_OFF_T_MAX to 0
1191
     again, so it has no uniqueness guarantee for large processings. Note: it
1192
     has no uniqueness either IFF more than one connection pool is used by the
1193
     libcurl application. */
1194
  curl_off_t id;
1195
  uint32_t master_mid; /* if set, this transfer belongs to a master */
1196
  multi_sub_xfer_done_cb *sub_xfer_done;
1197
1198
  /* `meta_hash` is a general key-value store for implementations
1199
   * with the lifetime of the easy handle.
1200
   * Elements need to be added with their own destructor to be invoked when
1201
   * the easy handle is cleaned up (see Curl_hash_add2()).*/
1202
  struct Curl_hash meta_hash;
1203
1204
#ifdef USE_LIBPSL
1205
  struct PslCache *psl;        /* The associated PSL cache. */
1206
#endif
1207
  struct SingleRequest req;    /* Request-specific data */
1208
  struct UserDefined set;      /* values set by the libcurl user */
1209
#ifndef CURL_DISABLE_COOKIES
1210
  struct CookieInfo *cookies;  /* the cookies, read from files and servers.
1211
                                  NOTE that the 'cookie' field in the
1212
                                  UserDefined struct defines if the "engine"
1213
                                  is to be used or not. */
1214
#endif
1215
#ifndef CURL_DISABLE_HSTS
1216
  struct hsts *hsts;
1217
#endif
1218
#ifndef CURL_DISABLE_ALTSVC
1219
  struct altsvcinfo *asi;      /* the alt-svc cache */
1220
#endif
1221
  struct Progress progress;    /* for all the progress meter data */
1222
  struct UrlState state;       /* struct for fields used for state info and
1223
                                  other dynamic purposes */
1224
#ifndef CURL_DISABLE_FTP
1225
  struct WildcardData *wildcard; /* wildcard download state info */
1226
#endif
1227
  struct PureInfo info;        /* stats, reports and info data */
1228
  struct curl_tlssessioninfo tsi; /* Information about the TLS session, only
1229
                                     valid after a client has asked for it */
1230
};
1231
1232
#define CURL_EASY_STR(d, id) \
1233
1.12M
  Curl_u8_strset_get(&(d)->set.strings, (uint8_t)(id))
1234
#define CURL_EASY_STR_SET(d, id, s, slen) \
1235
167k
  Curl_u8_strset_setx(&(d)->set.strings, (uint8_t)(id), s, slen)
1236
#define CURL_EASY_STR_SETN(d, id, s) \
1237
4.45k
  Curl_u8_strset_setn(&(d)->set.strings, (uint8_t)(id), s)
1238
#define CURL_EASY_STR_CLEAR(d, id) \
1239
0
  Curl_u8_strset_unset(&(d)->set.strings, (uint8_t)(id))
1240
#define CURL_EASY_STR_CLEAR0(d, id) \
1241
280k
  Curl_u8_strset_unset0(&(d)->set.strings, (uint8_t)(id))
1242
1243
#define LIBCURL_NAME "libcurl"
1244
1245
#endif /* HEADER_CURL_URLDATA_H */