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