lib: make more protocol specific struct fields #ifdefed

... so that they don't take up space if the protocols are disabled in
the build.

Closes #8944
This commit is contained in:
Daniel Stenberg 2022-06-01 14:30:55 +02:00
parent bb130871c0
commit 45de940ceb
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
10 changed files with 116 additions and 59 deletions

View File

@ -796,6 +796,7 @@ int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
#if defined(USE_NGTCP2) || defined(USE_QUICHE) || defined(USE_MSH3) #if defined(USE_NGTCP2) || defined(USE_QUICHE) || defined(USE_MSH3)
#define ENABLE_QUIC #define ENABLE_QUIC
#define USE_HTTP3
#endif #endif
#if defined(USE_UNIX_SOCKETS) && defined(WIN32) #if defined(USE_UNIX_SOCKETS) && defined(WIN32)

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -306,6 +306,14 @@ struct timeval {
# define HAVE_BOOL_T # define HAVE_BOOL_T
#endif #endif
/* the type we use for storing a single boolean bit */
#ifdef _MSC_VER
typedef bool bit;
#define BIT(x) bool x
#else
typedef unsigned int bit;
#define BIT(x) bit x:1
#endif
/* /*
* Redefine TRUE and FALSE too, to catch current use. With this * Redefine TRUE and FALSE too, to catch current use. With this

View File

@ -783,8 +783,9 @@ static CURLcode ftp_state_user(struct Curl_easy *data,
&conn->proto.ftpc.pp, "USER %s", &conn->proto.ftpc.pp, "USER %s",
conn->user?conn->user:""); conn->user?conn->user:"");
if(!result) { if(!result) {
struct ftp_conn *ftpc = &conn->proto.ftpc;
ftpc->ftp_trying_alternative = FALSE;
state(data, FTP_USER); state(data, FTP_USER);
data->state.ftp_trying_alternative = FALSE;
} }
return result; return result;
} }
@ -2622,13 +2623,13 @@ static CURLcode ftp_state_user_resp(struct Curl_easy *data,
(the server denies to log the specified user) */ (the server denies to log the specified user) */
if(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER] && if(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER] &&
!data->state.ftp_trying_alternative) { !ftpc->ftp_trying_alternative) {
/* Ok, USER failed. Let's try the supplied command. */ /* Ok, USER failed. Let's try the supplied command. */
result = result =
Curl_pp_sendf(data, &ftpc->pp, "%s", Curl_pp_sendf(data, &ftpc->pp, "%s",
data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]); data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]);
if(!result) { if(!result) {
data->state.ftp_trying_alternative = TRUE; ftpc->ftp_trying_alternative = TRUE;
state(data, FTP_USER); state(data, FTP_USER);
} }
} }

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -22,6 +22,8 @@
* *
***************************************************************************/ ***************************************************************************/
#include "curl_setup.h"
#include "pingpong.h" #include "pingpong.h"
#ifndef CURL_DISABLE_FTP #ifndef CURL_DISABLE_FTP
@ -149,6 +151,7 @@ struct ftp_conn {
curl_off_t known_filesize; /* file size is different from -1, if wildcard curl_off_t known_filesize; /* file size is different from -1, if wildcard
LIST parsing was done and wc_statemach set LIST parsing was done and wc_statemach set
it */ it */
BIT(ftp_trying_alternative);
}; };
#define DEFAULT_ACCEPT_TIMEOUT 60000 /* milliseconds == one minute */ #define DEFAULT_ACCEPT_TIMEOUT 60000 /* milliseconds == one minute */

View File

@ -299,6 +299,7 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
/* return if the condition prevented the document to get transferred */ /* return if the condition prevented the document to get transferred */
*param_longp = data->info.timecond ? 1L : 0L; *param_longp = data->info.timecond ? 1L : 0L;
break; break;
#ifndef CURL_DISABLE_RTSP
case CURLINFO_RTSP_CLIENT_CSEQ: case CURLINFO_RTSP_CLIENT_CSEQ:
*param_longp = data->state.rtsp_next_client_CSeq; *param_longp = data->state.rtsp_next_client_CSeq;
break; break;
@ -308,6 +309,7 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
case CURLINFO_RTSP_CSEQ_RECV: case CURLINFO_RTSP_CSEQ_RECV:
*param_longp = data->state.rtsp_CSeq_recv; *param_longp = data->state.rtsp_CSeq_recv;
break; break;
#endif
case CURLINFO_HTTP_VERSION: case CURLINFO_HTTP_VERSION:
switch(data->info.httpversion) { switch(data->info.httpversion) {
case 10: case 10:

View File

@ -52,7 +52,7 @@
#include "curl_memory.h" #include "curl_memory.h"
#include "memdebug.h" #include "memdebug.h"
#ifdef CURL_DO_LINEEND_CONV #if defined(CURL_DO_LINEEND_CONV) && !defined(CURL_DISABLE_FTP)
/* /*
* convert_lineends() changes CRLF (\r\n) end-of-line markers to a single LF * convert_lineends() changes CRLF (\r\n) end-of-line markers to a single LF
* (\n), with special processing for CRLF sequences that are split between two * (\n), with special processing for CRLF sequences that are split between two
@ -132,7 +132,7 @@ static size_t convert_lineends(struct Curl_easy *data,
} }
return size; return size;
} }
#endif /* CURL_DO_LINEEND_CONV */ #endif /* CURL_DO_LINEEND_CONV && !CURL_DISABLE_FTP */
#ifdef USE_RECV_BEFORE_SEND_WORKAROUND #ifdef USE_RECV_BEFORE_SEND_WORKAROUND
bool Curl_recv_has_postponed_data(struct connectdata *conn, int sockindex) bool Curl_recv_has_postponed_data(struct connectdata *conn, int sockindex)
@ -631,22 +631,15 @@ CURLcode Curl_client_write(struct Curl_easy *data,
char *ptr, char *ptr,
size_t len) size_t len)
{ {
struct connectdata *conn = data->conn; #if !defined(CURL_DISABLE_FTP) && defined(CURL_DO_LINEEND_CONV)
if(!len)
return CURLE_OK;
/* FTP data may need conversion. */ /* FTP data may need conversion. */
if((type & CLIENTWRITE_BODY) && if((type & CLIENTWRITE_BODY) &&
(conn->handler->protocol & PROTO_FAMILY_FTP) && (data->conn->handler->protocol & PROTO_FAMILY_FTP) &&
conn->proto.ftpc.transfertype == 'A') { data->conn->proto.ftpc.transfertype == 'A') {
#ifdef CURL_DO_LINEEND_CONV
/* convert end-of-line markers */ /* convert end-of-line markers */
len = convert_lineends(data, ptr, len); len = convert_lineends(data, ptr, len);
#endif /* CURL_DO_LINEEND_CONV */
} }
#endif
return chop_write(data, type, ptr, len); return chop_write(data, type, ptr, len);
} }

View File

@ -307,7 +307,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
break; break;
case CURLOPT_SERVER_RESPONSE_TIMEOUT: case CURLOPT_SERVER_RESPONSE_TIMEOUT:
/* /*
* Option that specifies how quickly an server response must be obtained * Option that specifies how quickly a server response must be obtained
* before it is considered failure. For pingpong protocols. * before it is considered failure. For pingpong protocols.
*/ */
arg = va_arg(param, long); arg = va_arg(param, long);
@ -1104,13 +1104,14 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
break; break;
} }
break; break;
#endif /* CURL_DISABLE_PROXY */
case CURLOPT_SOCKS5_AUTH: case CURLOPT_SOCKS5_AUTH:
data->set.socks5auth = va_arg(param, unsigned long); data->set.socks5auth = va_arg(param, unsigned long);
if(data->set.socks5auth & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI)) if(data->set.socks5auth & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI))
result = CURLE_NOT_BUILT_IN; result = CURLE_NOT_BUILT_IN;
break; break;
#endif /* CURL_DISABLE_PROXY */
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
case CURLOPT_SOCKS5_GSSAPI_NEC: case CURLOPT_SOCKS5_GSSAPI_NEC:
/* /*
@ -1393,15 +1394,17 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
data->set.connecttimeout = arg; data->set.connecttimeout = arg;
break; break;
#ifndef CURL_DISABLE_FTP
case CURLOPT_ACCEPTTIMEOUT_MS: case CURLOPT_ACCEPTTIMEOUT_MS:
/* /*
* The maximum time you allow curl to wait for server connect * The maximum time for curl to wait for FTP server connect
*/ */
arg = va_arg(param, long); arg = va_arg(param, long);
if(arg < 0) if(arg < 0)
return CURLE_BAD_FUNCTION_ARGUMENT; return CURLE_BAD_FUNCTION_ARGUMENT;
data->set.accepttimeout = arg; data->set.accepttimeout = arg;
break; break;
#endif
case CURLOPT_USERPWD: case CURLOPT_USERPWD:
/* /*

View File

@ -202,6 +202,7 @@ CURLcode Curl_fillreadbuffer(struct Curl_easy *data, size_t bytes,
} }
#endif #endif
#ifndef CURL_DISABLE_HTTP
/* if we are transmitting trailing data, we don't need to write /* if we are transmitting trailing data, we don't need to write
a chunk size so we skip this */ a chunk size so we skip this */
if(data->req.upload_chunky && if(data->req.upload_chunky &&
@ -211,7 +212,6 @@ CURLcode Curl_fillreadbuffer(struct Curl_easy *data, size_t bytes,
data->req.upload_fromhere += (8 + 2); /* 32bit hex + CRLF */ data->req.upload_fromhere += (8 + 2); /* 32bit hex + CRLF */
} }
#ifndef CURL_DISABLE_HTTP
if(data->state.trailers_state == TRAILERS_SENDING) { if(data->state.trailers_state == TRAILERS_SENDING) {
/* if we're here then that means that we already sent the last empty chunk /* if we're here then that means that we already sent the last empty chunk
but we didn't send a final CR LF, so we sent 0 CR LF. We then start but we didn't send a final CR LF, so we sent 0 CR LF. We then start
@ -267,6 +267,7 @@ CURLcode Curl_fillreadbuffer(struct Curl_easy *data, size_t bytes,
return CURLE_READ_ERROR; return CURLE_READ_ERROR;
} }
#ifndef CURL_DISABLE_HTTP
if(!data->req.forbidchunk && data->req.upload_chunky) { if(!data->req.forbidchunk && data->req.upload_chunky) {
/* if chunked Transfer-Encoding /* if chunked Transfer-Encoding
* build chunk: * build chunk:
@ -317,15 +318,12 @@ CURLcode Curl_fillreadbuffer(struct Curl_easy *data, size_t bytes,
/* always append ASCII CRLF to the data unless /* always append ASCII CRLF to the data unless
we have a valid trailer callback */ we have a valid trailer callback */
#ifndef CURL_DISABLE_HTTP
if((nread-hexlen) == 0 && if((nread-hexlen) == 0 &&
data->set.trailer_callback != NULL && data->set.trailer_callback != NULL &&
data->state.trailers_state == TRAILERS_NONE) { data->state.trailers_state == TRAILERS_NONE) {
data->state.trailers_state = TRAILERS_INITIALIZED; data->state.trailers_state = TRAILERS_INITIALIZED;
} }
else else {
#endif
{
memcpy(data->req.upload_fromhere + nread, memcpy(data->req.upload_fromhere + nread,
endofline_network, endofline_network,
strlen(endofline_network)); strlen(endofline_network));
@ -333,7 +331,6 @@ CURLcode Curl_fillreadbuffer(struct Curl_easy *data, size_t bytes,
} }
} }
#ifndef CURL_DISABLE_HTTP
if(data->state.trailers_state == TRAILERS_SENDING && if(data->state.trailers_state == TRAILERS_SENDING &&
!trailers_left(data)) { !trailers_left(data)) {
Curl_dyn_free(&data->state.trailers_buf); Curl_dyn_free(&data->state.trailers_buf);
@ -345,7 +342,6 @@ CURLcode Curl_fillreadbuffer(struct Curl_easy *data, size_t bytes,
infof(data, "Signaling end of chunked upload after trailers."); infof(data, "Signaling end of chunked upload after trailers.");
} }
else else
#endif
if((nread - hexlen) == 0 && if((nread - hexlen) == 0 &&
data->state.trailers_state != TRAILERS_INITIALIZED) { data->state.trailers_state != TRAILERS_INITIALIZED) {
/* mark this as done once this chunk is transferred */ /* mark this as done once this chunk is transferred */
@ -357,6 +353,7 @@ CURLcode Curl_fillreadbuffer(struct Curl_easy *data, size_t bytes,
if(added_crlf) if(added_crlf)
nread += strlen(endofline_network); /* for the added end of line */ nread += strlen(endofline_network); /* for the added end of line */
} }
#endif
*nreadp = nread; *nreadp = nread;
@ -1153,10 +1150,12 @@ CURLcode Curl_readwrite(struct connectdata *conn,
else else
fd_write = CURL_SOCKET_BAD; fd_write = CURL_SOCKET_BAD;
#if defined(USE_HTTP2) || defined(USE_HTTP3)
if(data->state.drain) { if(data->state.drain) {
select_res |= CURL_CSELECT_IN; select_res |= CURL_CSELECT_IN;
DEBUGF(infof(data, "Curl_readwrite: forcibly told to drain data")); DEBUGF(infof(data, "Curl_readwrite: forcibly told to drain data"));
} }
#endif
if(!select_res) /* Call for select()/poll() only, if read/write/error if(!select_res) /* Call for select()/poll() only, if read/write/error
status is not known. */ status is not known. */
@ -1402,7 +1401,6 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
if(result) if(result)
return result; return result;
data->state.wildcardmatch = data->set.wildcard_enabled;
data->state.followlocation = 0; /* reset the location-follow counter */ data->state.followlocation = 0; /* reset the location-follow counter */
data->state.this_is_a_follow = FALSE; /* reset this */ data->state.this_is_a_follow = FALSE; /* reset this */
data->state.errorbuf = FALSE; /* no error has occurred */ data->state.errorbuf = FALSE; /* no error has occurred */
@ -1457,6 +1455,7 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
data->state.authproxy.picked &= data->state.authproxy.want; data->state.authproxy.picked &= data->state.authproxy.want;
#ifndef CURL_DISABLE_FTP #ifndef CURL_DISABLE_FTP
data->state.wildcardmatch = data->set.wildcard_enabled;
if(data->state.wildcardmatch) { if(data->state.wildcardmatch) {
struct WildcardData *wc = &data->wildcard; struct WildcardData *wc = &data->wildcard;
if(wc->state < CURLWC_INIT) { if(wc->state < CURLWC_INIT) {
@ -1822,9 +1821,11 @@ CURLcode Curl_retry_request(struct Curl_easy *data, char **url)
if((data->req.bytecount + data->req.headerbytecount == 0) && if((data->req.bytecount + data->req.headerbytecount == 0) &&
conn->bits.reuse && conn->bits.reuse &&
(!data->set.opt_no_body (!data->set.opt_no_body || (conn->handler->protocol & PROTO_FAMILY_HTTP))
|| (conn->handler->protocol & PROTO_FAMILY_HTTP)) && #ifndef CURL_DISABLE_RTSP
(data->set.rtspreq != RTSPREQ_RECEIVE)) && (data->set.rtspreq != RTSPREQ_RECEIVE)
#endif
)
/* We got no data, we attempted to re-use a connection. For HTTP this /* We got no data, we attempted to re-use a connection. For HTTP this
can be a retry so we try again regardless if we expected a body. can be a retry so we try again regardless if we expected a body.
For other protocols we only try again only if we expected a body. For other protocols we only try again only if we expected a body.

View File

@ -508,7 +508,9 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
set->maxredirs = -1; /* allow any amount by default */ set->maxredirs = -1; /* allow any amount by default */
set->method = HTTPREQ_GET; /* Default HTTP request */ set->method = HTTPREQ_GET; /* Default HTTP request */
#ifndef CURL_DISABLE_RTSP
set->rtspreq = RTSPREQ_OPTIONS; /* Default RTSP request */ set->rtspreq = RTSPREQ_OPTIONS; /* Default RTSP request */
#endif
#ifndef CURL_DISABLE_FTP #ifndef CURL_DISABLE_FTP
set->ftp_use_epsv = TRUE; /* FTP defaults to EPSV operations */ set->ftp_use_epsv = TRUE; /* FTP defaults to EPSV operations */
set->ftp_use_eprt = TRUE; /* FTP defaults to EPRT operations */ set->ftp_use_eprt = TRUE; /* FTP defaults to EPRT operations */
@ -524,10 +526,12 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
set->proxyport = 0; set->proxyport = 0;
set->proxytype = CURLPROXY_HTTP; /* defaults to HTTP proxy */ set->proxytype = CURLPROXY_HTTP; /* defaults to HTTP proxy */
set->httpauth = CURLAUTH_BASIC; /* defaults to basic */ set->httpauth = CURLAUTH_BASIC; /* defaults to basic */
set->proxyauth = CURLAUTH_BASIC; /* defaults to basic */
#ifndef CURL_DISABLE_PROXY
set->proxyauth = CURLAUTH_BASIC; /* defaults to basic */
/* SOCKS5 proxy auth defaults to username/password + GSS-API */ /* SOCKS5 proxy auth defaults to username/password + GSS-API */
set->socks5auth = CURLAUTH_BASIC | CURLAUTH_GSSAPI; set->socks5auth = CURLAUTH_BASIC | CURLAUTH_GSSAPI;
#endif
/* make libcurl quiet by default: */ /* make libcurl quiet by default: */
set->hide_progress = TRUE; /* CURLOPT_NOPROGRESS changes these */ set->hide_progress = TRUE; /* CURLOPT_NOPROGRESS changes these */
@ -601,9 +605,12 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
#endif #endif
} }
#ifndef CURL_DISABLE_FTP
set->wildcard_enabled = FALSE; set->wildcard_enabled = FALSE;
set->chunk_bgn = ZERO_NULL; set->chunk_bgn = ZERO_NULL;
set->chunk_end = ZERO_NULL; set->chunk_end = ZERO_NULL;
set->fnmatch = ZERO_NULL;
#endif
set->tcp_keepalive = FALSE; set->tcp_keepalive = FALSE;
set->tcp_keepintvl = 60; set->tcp_keepintvl = 60;
set->tcp_keepidle = 60; set->tcp_keepidle = 60;
@ -616,7 +623,6 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
set->buffer_size = READBUFFER_SIZE; set->buffer_size = READBUFFER_SIZE;
set->upload_buffer_size = UPLOADBUFFER_DEFAULT; set->upload_buffer_size = UPLOADBUFFER_DEFAULT;
set->happy_eyeballs_timeout = CURL_HET_DEFAULT; set->happy_eyeballs_timeout = CURL_HET_DEFAULT;
set->fnmatch = ZERO_NULL;
set->upkeep_interval_ms = CURL_UPKEEP_INTERVAL_DEFAULT; set->upkeep_interval_ms = CURL_UPKEEP_INTERVAL_DEFAULT;
set->maxconnects = DEFAULT_CONNCACHE_SIZE; /* for easy handles */ set->maxconnects = DEFAULT_CONNCACHE_SIZE; /* for easy handles */
set->maxage_conn = 118; set->maxage_conn = 118;
@ -1103,12 +1109,17 @@ static void prune_dead_connections(struct Curl_easy *data)
} }
} }
#ifdef USE_SSH
static bool ssh_config_matches(struct connectdata *one, static bool ssh_config_matches(struct connectdata *one,
struct connectdata *two) struct connectdata *two)
{ {
return (Curl_safecmp(one->proto.sshc.rsa, two->proto.sshc.rsa) && return (Curl_safecmp(one->proto.sshc.rsa, two->proto.sshc.rsa) &&
Curl_safecmp(one->proto.sshc.rsa_pub, two->proto.sshc.rsa_pub)); Curl_safecmp(one->proto.sshc.rsa_pub, two->proto.sshc.rsa_pub));
} }
#else
#define ssh_config_matches(x,y) FALSE
#endif
/* /*
* Given one filled in connection struct (named needle), this function should * Given one filled in connection struct (named needle), this function should
* detect if there already is one that has all the significant details * detect if there already is one that has all the significant details

View File

@ -180,15 +180,6 @@ typedef CURLcode (*Curl_datastream)(struct Curl_easy *data,
#define GOOD_EASY_HANDLE(x) \ #define GOOD_EASY_HANDLE(x) \
((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER)) ((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER))
/* the type we use for storing a single boolean bit */
#ifdef _MSC_VER
typedef bool bit;
#define BIT(x) bool x
#else
typedef unsigned int bit;
#define BIT(x) bit x:1
#endif
#ifdef HAVE_GSSAPI #ifdef HAVE_GSSAPI
/* Types needed for krb5-ftp connections */ /* Types needed for krb5-ftp connections */
struct krb5buffer { struct krb5buffer {
@ -1089,18 +1080,38 @@ struct connectdata {
struct dynbuf trailer; struct dynbuf trailer;
union { union {
#ifndef CURL_DISABLE_FTP
struct ftp_conn ftpc; struct ftp_conn ftpc;
#endif
#ifndef CURL_DISABLE_HTTP
struct http_conn httpc; struct http_conn httpc;
#endif
#ifdef USE_SSH
struct ssh_conn sshc; struct ssh_conn sshc;
#endif
#ifndef CURL_DISABLE_TFTP
struct tftp_state_data *tftpc; struct tftp_state_data *tftpc;
#endif
#ifndef CURL_DISABLE_IMAP
struct imap_conn imapc; struct imap_conn imapc;
#endif
#ifndef CURL_DISABLE_POP3
struct pop3_conn pop3c; struct pop3_conn pop3c;
#endif
#ifndef CURL_DISABLE_SMTP
struct smtp_conn smtpc; struct smtp_conn smtpc;
#endif
#ifndef CURL_DISABLE_RTSP
struct rtsp_conn rtspc; struct rtsp_conn rtspc;
#endif
#ifndef CURL_DISABLE_SMB
struct smb_conn smbc; struct smb_conn smbc;
#endif
void *rtmp; void *rtmp;
struct ldapconninfo *ldapc; struct ldapconninfo *ldapc;
#ifndef CURL_DISABLE_MQTT
struct mqtt_conn mqtt; struct mqtt_conn mqtt;
#endif
} proto; } proto;
struct http_connect_state *connect_state; /* for HTTP CONNECT */ struct http_connect_state *connect_state; /* for HTTP CONNECT */
@ -1354,9 +1365,10 @@ struct UrlState {
/* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */ /* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */
void (*prev_signal)(int sig); void (*prev_signal)(int sig);
#endif #endif
#ifndef CURL_DISABLE_CRYPTO_AUTH
struct digestdata digest; /* state data for host Digest auth */ struct digestdata digest; /* state data for host Digest auth */
struct digestdata proxydigest; /* state data for proxy Digest auth */ struct digestdata proxydigest; /* state data for proxy Digest auth */
#endif
struct auth authhost; /* auth details for host */ struct auth authhost; /* auth details for host */
struct auth authproxy; /* auth details for proxy */ struct auth authproxy; /* auth details for proxy */
#ifdef USE_CURL_ASYNC #ifdef USE_CURL_ASYNC
@ -1372,7 +1384,7 @@ struct UrlState {
struct Curl_llist timeoutlist; /* list of pending timeouts */ struct Curl_llist timeoutlist; /* list of pending timeouts */
struct time_node expires[EXPIRE_LAST]; /* nodes for each expire type */ struct time_node expires[EXPIRE_LAST]; /* nodes for each expire type */
/* a place to store the most recently set FTP entrypath */ /* a place to store the most recently set (S)FTP entrypath */
char *most_recent_ftp_entrypath; char *most_recent_ftp_entrypath;
unsigned char httpwant; /* when non-zero, a specific HTTP version requested unsigned char httpwant; /* when non-zero, a specific HTTP version requested
to be used in the library's request(s) */ to be used in the library's request(s) */
@ -1391,30 +1403,36 @@ struct UrlState {
this syntax. */ this syntax. */
curl_off_t resume_from; /* continue [ftp] transfer from here */ curl_off_t resume_from; /* continue [ftp] transfer from here */
#ifndef CURL_DISABLE_RTSP
/* This RTSP state information survives requests and connections */ /* This RTSP state information survives requests and connections */
long rtsp_next_client_CSeq; /* the session's next client CSeq */ long rtsp_next_client_CSeq; /* the session's next client CSeq */
long rtsp_next_server_CSeq; /* the session's next server CSeq */ long rtsp_next_server_CSeq; /* the session's next server CSeq */
long rtsp_CSeq_recv; /* most recent CSeq received */ long rtsp_CSeq_recv; /* most recent CSeq received */
#endif
curl_off_t infilesize; /* size of file to upload, -1 means unknown. curl_off_t infilesize; /* size of file to upload, -1 means unknown.
Copied from set.filesize at start of operation */ Copied from set.filesize at start of operation */
#if defined(USE_HTTP2) || defined(USE_HTTP3)
size_t drain; /* Increased when this stream has data to read, even if its size_t drain; /* Increased when this stream has data to read, even if its
socket is not necessarily is readable. Decreased when socket is not necessarily is readable. Decreased when
checked. */ checked. */
#endif
curl_read_callback fread_func; /* read callback/function */ curl_read_callback fread_func; /* read callback/function */
void *in; /* CURLOPT_READDATA */ void *in; /* CURLOPT_READDATA */
#ifdef USE_HTTP2
struct Curl_easy *stream_depends_on; struct Curl_easy *stream_depends_on;
int stream_weight; int stream_weight;
#endif
CURLU *uh; /* URL handle for the current parsed URL */ CURLU *uh; /* URL handle for the current parsed URL */
struct urlpieces up; struct urlpieces up;
Curl_HttpReq httpreq; /* what kind of HTTP request (if any) is this */ Curl_HttpReq httpreq; /* what kind of HTTP request (if any) is this */
char *url; /* work URL, copied from UserDefined */ char *url; /* work URL, copied from UserDefined */
char *referer; /* referer string */ char *referer; /* referer string */
#ifndef CURL_DISABLE_COOKIES
struct curl_slist *cookielist; /* list of cookie files set by struct curl_slist *cookielist; /* list of cookie files set by
curl_easy_setopt(COOKIEFILE) calls */ curl_easy_setopt(COOKIEFILE) calls */
#endif
struct curl_slist *resolve; /* set to point to the set.resolve list when struct curl_slist *resolve; /* set to point to the set.resolve list when
this should be dealt with in pretransfer */ this should be dealt with in pretransfer */
#ifndef CURL_DISABLE_HTTP #ifndef CURL_DISABLE_HTTP
@ -1424,9 +1442,9 @@ struct UrlState {
struct Curl_llist httphdrs; /* received headers */ struct Curl_llist httphdrs; /* received headers */
struct curl_header headerout; /* for external purposes */ struct curl_header headerout; /* for external purposes */
struct Curl_header_store *prevhead; /* the latest added header */ struct Curl_header_store *prevhead; /* the latest added header */
#endif
trailers_state trailers_state; /* whether we are sending trailers trailers_state trailers_state; /* whether we are sending trailers
and what stage are we at */ and what stage are we at */
#endif
#ifdef USE_HYPER #ifdef USE_HYPER
bool hconnect; /* set if a CONNECT request */ bool hconnect; /* set if a CONNECT request */
CURLcode hresult; /* used to pass return codes back from hyper callbacks */ CURLcode hresult; /* used to pass return codes back from hyper callbacks */
@ -1470,7 +1488,6 @@ struct UrlState {
is always set TRUE when curl_easy_perform() is called. */ is always set TRUE when curl_easy_perform() is called. */
BIT(authproblem); /* TRUE if there's some problem authenticating */ BIT(authproblem); /* TRUE if there's some problem authenticating */
/* set after initial USER failure, to prevent an authentication loop */ /* set after initial USER failure, to prevent an authentication loop */
BIT(ftp_trying_alternative);
BIT(wildcardmatch); /* enable wildcard matching */ BIT(wildcardmatch); /* enable wildcard matching */
BIT(expect100header); /* TRUE if we added Expect: 100-continue */ BIT(expect100header); /* TRUE if we added Expect: 100-continue */
BIT(disableexpect); /* TRUE if Expect: is disabled due to a previous BIT(disableexpect); /* TRUE if Expect: is disabled due to a previous
@ -1629,11 +1646,12 @@ struct UserDefined {
void *out; /* CURLOPT_WRITEDATA */ void *out; /* CURLOPT_WRITEDATA */
void *in_set; /* CURLOPT_READDATA */ void *in_set; /* CURLOPT_READDATA */
void *writeheader; /* write the header to this if non-NULL */ void *writeheader; /* write the header to this if non-NULL */
void *rtp_out; /* write RTP to this if non-NULL */
long use_port; /* which port to use (when not using default) */ long use_port; /* which port to use (when not using default) */
unsigned long httpauth; /* kind of HTTP authentication to use (bitmask) */ unsigned long httpauth; /* kind of HTTP authentication to use (bitmask) */
unsigned long proxyauth; /* kind of proxy authentication to use (bitmask) */ unsigned long proxyauth; /* kind of proxy authentication to use (bitmask) */
#ifndef CURL_DISABLE_PROXY
unsigned long socks5auth;/* kind of SOCKS5 authentication to use (bitmask) */ unsigned long socks5auth;/* kind of SOCKS5 authentication to use (bitmask) */
#endif
long maxredirs; /* maximum no. of http(s) redirects to follow, set to -1 long maxredirs; /* maximum no. of http(s) redirects to follow, set to -1
for infinity */ for infinity */
@ -1676,14 +1694,15 @@ struct UserDefined {
void *ioctl_client; /* pointer to pass to the ioctl callback */ void *ioctl_client; /* pointer to pass to the ioctl callback */
long timeout; /* in milliseconds, 0 means no timeout */ long timeout; /* in milliseconds, 0 means no timeout */
long connecttimeout; /* in milliseconds, 0 means no timeout */ long connecttimeout; /* in milliseconds, 0 means no timeout */
long accepttimeout; /* in milliseconds, 0 means no timeout */
long happy_eyeballs_timeout; /* in milliseconds, 0 is a valid value */ long happy_eyeballs_timeout; /* in milliseconds, 0 is a valid value */
long server_response_timeout; /* in milliseconds, 0 means no timeout */ long server_response_timeout; /* in milliseconds, 0 means no timeout */
long maxage_conn; /* in seconds, max idle time to allow a connection that long maxage_conn; /* in seconds, max idle time to allow a connection that
is to be reused */ is to be reused */
long maxlifetime_conn; /* in seconds, max time since creation to allow a long maxlifetime_conn; /* in seconds, max time since creation to allow a
connection that is to be reused */ connection that is to be reused */
#ifndef CURL_DISABLE_TFTP
long tftp_blksize; /* in bytes, 0 means use default */ long tftp_blksize; /* in bytes, 0 means use default */
#endif
curl_off_t filesize; /* size of file to upload, -1 means unknown */ curl_off_t filesize; /* size of file to upload, -1 means unknown */
long low_speed_limit; /* bytes/second */ long low_speed_limit; /* bytes/second */
long low_speed_time; /* number of seconds */ long low_speed_time; /* number of seconds */
@ -1703,7 +1722,9 @@ struct UserDefined {
the transfer on source host */ the transfer on source host */
struct curl_slist *source_postquote; /* in 3rd party transfer mode - after struct curl_slist *source_postquote; /* in 3rd party transfer mode - after
the transfer on source host */ the transfer on source host */
#ifndef CURL_DISABLE_TELNET
struct curl_slist *telnet_options; /* linked list of telnet options */ struct curl_slist *telnet_options; /* linked list of telnet options */
#endif
struct curl_slist *resolve; /* list of names to add/remove from struct curl_slist *resolve; /* list of names to add/remove from
DNS cache */ DNS cache */
struct curl_slist *connect_to; /* list of host:port mappings to override struct curl_slist *connect_to; /* list of host:port mappings to override
@ -1732,6 +1753,7 @@ struct UserDefined {
curl_ftpfile ftp_filemethod; /* how to get to a file when FTP is used */ curl_ftpfile ftp_filemethod; /* how to get to a file when FTP is used */
curl_ftpauth ftpsslauth; /* what AUTH XXX to be attempted */ curl_ftpauth ftpsslauth; /* what AUTH XXX to be attempted */
curl_ftpccc ftp_ccc; /* FTP CCC options */ curl_ftpccc ftp_ccc; /* FTP CCC options */
long accepttimeout; /* in milliseconds, 0 means no timeout */
#endif #endif
int ftp_create_missing_dirs; /* 1 - create directories that don't exist int ftp_create_missing_dirs; /* 1 - create directories that don't exist
2 - the same but also allow MKD to fail once 2 - the same but also allow MKD to fail once
@ -1755,10 +1777,14 @@ struct UserDefined {
unsigned int allowed_protocols; unsigned int allowed_protocols;
unsigned int redir_protocols; unsigned int redir_protocols;
unsigned int mime_options; /* Mime option flags. */ unsigned int mime_options; /* Mime option flags. */
struct curl_slist *mail_rcpt; /* linked list of mail recipients */
#ifndef CURL_DISABLE_RTSP
void *rtp_out; /* write RTP to this if non-NULL */
/* Common RTSP header options */ /* Common RTSP header options */
Curl_RtspReq rtspreq; /* RTSP request type */ Curl_RtspReq rtspreq; /* RTSP request type */
long rtspversion; /* like httpversion, for RTSP */ long rtspversion; /* like httpversion, for RTSP */
#endif
#ifndef CURL_DISABLE_FTP
curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer
starts */ starts */
curl_chunk_end_callback chunk_end; /* called after part transferring curl_chunk_end_callback chunk_end; /* called after part transferring
@ -1766,7 +1792,7 @@ struct UserDefined {
curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds
to pattern (e.g. if WILDCARDMATCH is on) */ to pattern (e.g. if WILDCARDMATCH is on) */
void *fnmatch_data; void *fnmatch_data;
#endif
long gssapi_delegation; /* GSS-API credential delegation, see the long gssapi_delegation; /* GSS-API credential delegation, see the
documentation of CURLOPT_GSSAPI_DELEGATION */ documentation of CURLOPT_GSSAPI_DELEGATION */
@ -1776,21 +1802,29 @@ struct UserDefined {
size_t maxconnects; /* Max idle connections in the connection cache */ size_t maxconnects; /* Max idle connections in the connection cache */
long expect_100_timeout; /* in milliseconds */ long expect_100_timeout; /* in milliseconds */
#ifdef USE_HTTP2
struct Curl_easy *stream_depends_on; struct Curl_easy *stream_depends_on;
int stream_weight; int stream_weight;
struct Curl_http2_dep *stream_dependents; struct Curl_http2_dep *stream_dependents;
#endif
curl_resolver_start_callback resolver_start; /* optional callback called curl_resolver_start_callback resolver_start; /* optional callback called
before resolver start */ before resolver start */
void *resolver_start_client; /* pointer to pass to resolver start callback */ void *resolver_start_client; /* pointer to pass to resolver start callback */
long upkeep_interval_ms; /* Time between calls for connection upkeep. */ long upkeep_interval_ms; /* Time between calls for connection upkeep. */
multidone_func fmultidone; multidone_func fmultidone;
#ifndef CURL_DISABLE_DOH
struct Curl_easy *dohfor; /* this is a DoH request for that transfer */ struct Curl_easy *dohfor; /* this is a DoH request for that transfer */
#endif
CURLU *uh; /* URL handle for the current parsed URL */ CURLU *uh; /* URL handle for the current parsed URL */
void *trailer_data; /* pointer to pass to trailer data callback */ void *trailer_data; /* pointer to pass to trailer data callback */
curl_trailer_callback trailer_callback; /* trailing data callback */ curl_trailer_callback trailer_callback; /* trailing data callback */
char keep_post; /* keep POSTs as POSTs after a 30x request; each char keep_post; /* keep POSTs as POSTs after a 30x request; each
bit represents a request, from 301 to 303 */ bit represents a request, from 301 to 303 */
#ifndef CURL_DISABLE_SMTP
struct curl_slist *mail_rcpt; /* linked list of mail recipients */
BIT(mail_rcpt_allowfails); /* allow RCPT TO command to fail for some
recipients */
#endif
BIT(is_fread_set); /* has read callback been set to non-NULL? */ BIT(is_fread_set); /* has read callback been set to non-NULL? */
#ifndef CURL_DISABLE_TFTP #ifndef CURL_DISABLE_TFTP
BIT(tftp_no_options); /* do not send TFTP options requests */ BIT(tftp_no_options); /* do not send TFTP options requests */
@ -1815,6 +1849,7 @@ struct UserDefined {
BIT(ftp_use_pret); /* if PRET is to be used before PASV or not */ BIT(ftp_use_pret); /* if PRET is to be used before PASV or not */
BIT(ftp_skip_ip); /* skip the IP address the FTP server passes on to BIT(ftp_skip_ip); /* skip the IP address the FTP server passes on to
us */ us */
BIT(wildcard_enabled); /* enable wildcard matching */
#endif #endif
BIT(hide_progress); /* don't use the progress meter */ BIT(hide_progress); /* don't use the progress meter */
BIT(http_fail_on_error); /* fail on HTTP error codes >= 400 */ BIT(http_fail_on_error); /* fail on HTTP error codes >= 400 */
@ -1846,7 +1881,6 @@ struct UserDefined {
BIT(socks5_gssapi_nec); /* Flag to support NEC SOCKS5 server */ BIT(socks5_gssapi_nec); /* Flag to support NEC SOCKS5 server */
#endif #endif
BIT(sasl_ir); /* Enable/disable SASL initial response */ BIT(sasl_ir); /* Enable/disable SASL initial response */
BIT(wildcard_enabled); /* enable wildcard matching */
BIT(tcp_keepalive); /* use TCP keepalives */ BIT(tcp_keepalive); /* use TCP keepalives */
BIT(tcp_fastopen); /* use TCP Fast Open */ BIT(tcp_fastopen); /* use TCP Fast Open */
BIT(ssl_enable_npn); /* TLS NPN extension? */ BIT(ssl_enable_npn); /* TLS NPN extension? */
@ -1869,8 +1903,6 @@ struct UserDefined {
BIT(doh_verifystatus); /* DoH certificate status verification */ BIT(doh_verifystatus); /* DoH certificate status verification */
#endif #endif
BIT(http09_allowed); /* allow HTTP/0.9 responses */ BIT(http09_allowed); /* allow HTTP/0.9 responses */
BIT(mail_rcpt_allowfails); /* allow RCPT TO command to fail for some
recipients */
}; };
struct Names { struct Names {
@ -1932,10 +1964,12 @@ struct Curl_easy {
#endif #endif
struct SingleRequest req; /* Request-specific data */ struct SingleRequest req; /* Request-specific data */
struct UserDefined set; /* values set by the libcurl user */ struct UserDefined set; /* values set by the libcurl user */
#ifndef CURL_DISABLE_COOKIES
struct CookieInfo *cookies; /* the cookies, read from files and servers. struct CookieInfo *cookies; /* the cookies, read from files and servers.
NOTE that the 'cookie' field in the NOTE that the 'cookie' field in the
UserDefined struct defines if the "engine" UserDefined struct defines if the "engine"
is to be used or not. */ is to be used or not. */
#endif
#ifndef CURL_DISABLE_HSTS #ifndef CURL_DISABLE_HSTS
struct hsts *hsts; struct hsts *hsts;
#endif #endif