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