urldata: merge "struct DynamicStatic" into "struct UrlState"

Both were used for the same purposes and there was no logical separation
between them. Combined, this also saves 16 bytes in less holes in my
test build.

Closes #6798
This commit is contained in:
Daniel Stenberg 2021-03-26 14:25:45 +01:00
parent d003b0213a
commit 95cbcec8f9
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
16 changed files with 127 additions and 141 deletions

View File

@ -810,8 +810,8 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done)
#endif #endif
Curl_safefree(data->state.aptr.ref); Curl_safefree(data->state.aptr.ref);
if(data->change.referer && !Curl_checkheaders(data, "Referer")) { if(data->state.referer && !Curl_checkheaders(data, "Referer")) {
data->state.aptr.ref = aprintf("Referer: %s\r\n", data->change.referer); data->state.aptr.ref = aprintf("Referer: %s\r\n", data->state.referer);
if(!data->state.aptr.ref) if(!data->state.aptr.ref)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
if(Curl_hyper_header(data, headers, data->state.aptr.ref)) if(Curl_hyper_header(data, headers, data->state.aptr.ref))

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2021, 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
@ -348,7 +348,7 @@ static char *sanitize_cookie_path(const char *cookie_path)
*/ */
void Curl_cookie_loadfiles(struct Curl_easy *data) void Curl_cookie_loadfiles(struct Curl_easy *data)
{ {
struct curl_slist *list = data->change.cookielist; struct curl_slist *list = data->state.cookielist;
if(list) { if(list) {
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
while(list) { while(list) {
@ -365,8 +365,8 @@ void Curl_cookie_loadfiles(struct Curl_easy *data)
data->cookies = newcookies; data->cookies = newcookies;
list = list->next; list = list->next;
} }
curl_slist_free_all(data->change.cookielist); /* clean up list */ curl_slist_free_all(data->state.cookielist); /* clean up list */
data->change.cookielist = NULL; /* don't do this again! */ data->state.cookielist = NULL; /* don't do this again! */
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
} }
} }
@ -1656,7 +1656,7 @@ struct curl_slist *Curl_cookie_list(struct Curl_easy *data)
void Curl_flush_cookies(struct Curl_easy *data, bool cleanup) void Curl_flush_cookies(struct Curl_easy *data, bool cleanup)
{ {
if(data->set.str[STRING_COOKIEJAR]) { if(data->set.str[STRING_COOKIEJAR]) {
if(data->change.cookielist) { if(data->state.cookielist) {
/* If there is a list of cookie files to read, do it first so that /* If there is a list of cookie files to read, do it first so that
we have all the told files read before we write the new jar. we have all the told files read before we write the new jar.
Curl_cookie_loadfiles() LOCKS and UNLOCKS the share itself! */ Curl_cookie_loadfiles() LOCKS and UNLOCKS the share itself! */
@ -1671,11 +1671,11 @@ void Curl_flush_cookies(struct Curl_easy *data, bool cleanup)
data->set.str[STRING_COOKIEJAR]); data->set.str[STRING_COOKIEJAR]);
} }
else { else {
if(cleanup && data->change.cookielist) { if(cleanup && data->state.cookielist) {
/* since nothing is written, we can just free the list of cookie file /* since nothing is written, we can just free the list of cookie file
names */ names */
curl_slist_free_all(data->change.cookielist); /* clean up list */ curl_slist_free_all(data->state.cookielist); /* clean up list */
data->change.cookielist = NULL; data->state.cookielist = NULL;
} }
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
} }

View File

@ -204,7 +204,7 @@ static CURLcode rtmp_setup_connection(struct Curl_easy *data,
RTMP_Init(r); RTMP_Init(r);
RTMP_SetBufferMS(r, DEF_BUFTIME); RTMP_SetBufferMS(r, DEF_BUFTIME);
if(!RTMP_SetupURL(r, data->change.url)) { if(!RTMP_SetupURL(r, data->state.url)) {
RTMP_Free(r); RTMP_Free(r);
return CURLE_URL_MALFORMAT; return CURLE_URL_MALFORMAT;
} }

View File

@ -810,7 +810,7 @@ static CURLcode dupset(struct Curl_easy *dst, struct Curl_easy *src)
result = Curl_mime_duppart(&dst->set.mimepost, &src->set.mimepost); result = Curl_mime_duppart(&dst->set.mimepost, &src->set.mimepost);
if(src->set.resolve) if(src->set.resolve)
dst->change.resolve = dst->set.resolve; dst->state.resolve = dst->set.resolve;
return result; return result;
} }
@ -858,25 +858,25 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
} }
/* duplicate all values in 'change' */ /* duplicate all values in 'change' */
if(data->change.cookielist) { if(data->state.cookielist) {
outcurl->change.cookielist = outcurl->state.cookielist =
Curl_slist_duplicate(data->change.cookielist); Curl_slist_duplicate(data->state.cookielist);
if(!outcurl->change.cookielist) if(!outcurl->state.cookielist)
goto fail; goto fail;
} }
if(data->change.url) { if(data->state.url) {
outcurl->change.url = strdup(data->change.url); outcurl->state.url = strdup(data->state.url);
if(!outcurl->change.url) if(!outcurl->state.url)
goto fail; goto fail;
outcurl->change.url_alloc = TRUE; outcurl->state.url_alloc = TRUE;
} }
if(data->change.referer) { if(data->state.referer) {
outcurl->change.referer = strdup(data->change.referer); outcurl->state.referer = strdup(data->state.referer);
if(!outcurl->change.referer) if(!outcurl->state.referer)
goto fail; goto fail;
outcurl->change.referer_alloc = TRUE; outcurl->state.referer_alloc = TRUE;
} }
/* Reinitialize an SSL engine for the new handle /* Reinitialize an SSL engine for the new handle
@ -947,12 +947,12 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
fail: fail:
if(outcurl) { if(outcurl) {
curl_slist_free_all(outcurl->change.cookielist); curl_slist_free_all(outcurl->state.cookielist);
outcurl->change.cookielist = NULL; outcurl->state.cookielist = NULL;
Curl_safefree(outcurl->state.buffer); Curl_safefree(outcurl->state.buffer);
Curl_dyn_free(&outcurl->state.headerb); Curl_dyn_free(&outcurl->state.headerb);
Curl_safefree(outcurl->change.url); Curl_safefree(outcurl->state.url);
Curl_safefree(outcurl->change.referer); Curl_safefree(outcurl->state.referer);
Curl_altsvc_cleanup(&outcurl->asi); Curl_altsvc_cleanup(&outcurl->asi);
Curl_hsts_cleanup(&outcurl->hsts); Curl_hsts_cleanup(&outcurl->hsts);
Curl_freeset(outcurl); Curl_freeset(outcurl);

View File

@ -94,7 +94,7 @@ static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info,
{ {
switch(info) { switch(info) {
case CURLINFO_EFFECTIVE_URL: case CURLINFO_EFFECTIVE_URL:
*param_charp = data->change.url?data->change.url:(char *)""; *param_charp = data->state.url?data->state.url:(char *)"";
break; break;
case CURLINFO_EFFECTIVE_METHOD: { case CURLINFO_EFFECTIVE_METHOD: {
const char *m = data->set.str[STRING_CUSTOMREQUEST]; const char *m = data->set.str[STRING_CUSTOMREQUEST];
@ -147,7 +147,7 @@ static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info,
break; break;
case CURLINFO_REFERER: case CURLINFO_REFERER:
/* Return the referrer header for this request, or NULL if unset */ /* Return the referrer header for this request, or NULL if unset */
*param_charp = data->change.referer; *param_charp = data->state.referer;
break; break;
case CURLINFO_PRIMARY_IP: case CURLINFO_PRIMARY_IP:
/* Return the ip address of the most recent (primary) connection */ /* Return the ip address of the most recent (primary) connection */

View File

@ -269,7 +269,7 @@ static struct Curl_dns_entry *fetch_addr(struct Curl_easy *data,
dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len + 1); dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len + 1);
/* No entry found in cache, check if we might have a wildcard entry */ /* No entry found in cache, check if we might have a wildcard entry */
if(!dns && data->change.wildcard_resolve) { if(!dns && data->state.wildcard_resolve) {
create_hostcache_id("*", port, entry_id, sizeof(entry_id)); create_hostcache_id("*", port, entry_id, sizeof(entry_id));
entry_len = strlen(entry_id); entry_len = strlen(entry_id);
@ -878,9 +878,9 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
int port = 0; int port = 0;
/* Default is no wildcard found */ /* Default is no wildcard found */
data->change.wildcard_resolve = false; data->state.wildcard_resolve = false;
for(hostp = data->change.resolve; hostp; hostp = hostp->next) { for(hostp = data->state.resolve; hostp; hostp = hostp->next) {
char entry_id[MAX_HOSTCACHE_LEN]; char entry_id[MAX_HOSTCACHE_LEN];
if(!hostp->data) if(!hostp->data)
continue; continue;
@ -1061,11 +1061,11 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
if(hostname[0] == '*' && hostname[1] == '\0') { if(hostname[0] == '*' && hostname[1] == '\0') {
infof(data, "RESOLVE %s:%d is wildcard, enabling wildcard checks\n", infof(data, "RESOLVE %s:%d is wildcard, enabling wildcard checks\n",
hostname, port); hostname, port);
data->change.wildcard_resolve = true; data->state.wildcard_resolve = true;
} }
} }
} }
data->change.resolve = NULL; /* dealt with now */ data->state.resolve = NULL; /* dealt with now */
return CURLE_OK; return CURLE_OK;
} }

View File

@ -622,7 +622,7 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
we must make sure to free it before allocating a new one. As figured we must make sure to free it before allocating a new one. As figured
out in bug #2284386 */ out in bug #2284386 */
Curl_safefree(data->req.newurl); Curl_safefree(data->req.newurl);
data->req.newurl = strdup(data->change.url); /* clone URL */ data->req.newurl = strdup(data->state.url); /* clone URL */
if(!data->req.newurl) if(!data->req.newurl)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
@ -635,7 +635,7 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
we didn't try HEAD or GET */ we didn't try HEAD or GET */
if((data->state.httpreq != HTTPREQ_GET) && if((data->state.httpreq != HTTPREQ_GET) &&
(data->state.httpreq != HTTPREQ_HEAD)) { (data->state.httpreq != HTTPREQ_HEAD)) {
data->req.newurl = strdup(data->change.url); /* clone URL */ data->req.newurl = strdup(data->state.url); /* clone URL */
if(!data->req.newurl) if(!data->req.newurl)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
data->state.authhost.done = TRUE; data->state.authhost.done = TRUE;
@ -950,7 +950,7 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
CURLcode result = Curl_input_negotiate(data, conn, proxy, auth); CURLcode result = Curl_input_negotiate(data, conn, proxy, auth);
if(!result) { if(!result) {
DEBUGASSERT(!data->req.newurl); DEBUGASSERT(!data->req.newurl);
data->req.newurl = strdup(data->change.url); data->req.newurl = strdup(data->state.url);
if(!data->req.newurl) if(!data->req.newurl)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
data->state.authproblem = FALSE; data->state.authproblem = FALSE;
@ -3017,8 +3017,8 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done)
} }
Curl_safefree(data->state.aptr.ref); Curl_safefree(data->state.aptr.ref);
if(data->change.referer && !Curl_checkheaders(data, "Referer")) { if(data->state.referer && !Curl_checkheaders(data, "Referer")) {
data->state.aptr.ref = aprintf("Referer: %s\r\n", data->change.referer); data->state.aptr.ref = aprintf("Referer: %s\r\n", data->state.referer);
if(!data->state.aptr.ref) if(!data->state.aptr.ref)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
@ -3137,7 +3137,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done)
*data->set.str[STRING_ENCODING] && *data->set.str[STRING_ENCODING] &&
data->state.aptr.accept_encoding)? data->state.aptr.accept_encoding)?
data->state.aptr.accept_encoding:"", data->state.aptr.accept_encoding:"",
(data->change.referer && data->state.aptr.ref)? (data->state.referer && data->state.aptr.ref)?
data->state.aptr.ref:"" /* Referer: <data> */, data->state.aptr.ref:"" /* Referer: <data> */,
#ifndef CURL_DISABLE_PROXY #ifndef CURL_DISABLE_PROXY
(conn->bits.httpproxy && (conn->bits.httpproxy &&
@ -4008,7 +4008,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
infof(data, "Got 417 while waiting for a 100\n"); infof(data, "Got 417 while waiting for a 100\n");
data->state.disableexpect = TRUE; data->state.disableexpect = TRUE;
DEBUGASSERT(!data->req.newurl); DEBUGASSERT(!data->req.newurl);
data->req.newurl = strdup(data->change.url); data->req.newurl = strdup(data->state.url);
Curl_done_sending(data, k); Curl_done_sending(data, k);
} }
else if(data->set.http_keep_sending_on_error) { else if(data->set.http_keep_sending_on_error) {

View File

@ -527,10 +527,10 @@ static int set_transfer_url(struct Curl_easy *data,
return 4; return 4;
curl_url_cleanup(u); curl_url_cleanup(u);
if(data->change.url_alloc) if(data->state.url_alloc)
free(data->change.url); free(data->state.url);
data->change.url_alloc = TRUE; data->state.url_alloc = TRUE;
data->change.url = url; data->state.url = url;
return 0; return 0;
} }

View File

@ -296,10 +296,10 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
*done = TRUE; /* unconditionally */ *done = TRUE; /* unconditionally */
infof(data, "LDAP local: LDAP Vendor = %s ; LDAP Version = %d\n", infof(data, "LDAP local: LDAP Vendor = %s ; LDAP Version = %d\n",
LDAP_VENDOR_NAME, LDAP_VENDOR_VERSION); LDAP_VENDOR_NAME, LDAP_VENDOR_VERSION);
infof(data, "LDAP local: %s\n", data->change.url); infof(data, "LDAP local: %s\n", data->state.url);
#ifdef HAVE_LDAP_URL_PARSE #ifdef HAVE_LDAP_URL_PARSE
rc = ldap_url_parse(data->change.url, &ludp); rc = ldap_url_parse(data->state.url, &ludp);
#else #else
rc = _ldap_url_parse(data, conn, &ludp); rc = _ldap_url_parse(data, conn, &ludp);
#endif #endif

View File

@ -2164,7 +2164,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
data->state.errorbuf = FALSE; data->state.errorbuf = FALSE;
if(!newurl) if(!newurl)
/* typically for HTTP_1_1_REQUIRED error on first flight */ /* typically for HTTP_1_1_REQUIRED error on first flight */
newurl = strdup(data->change.url); newurl = strdup(data->state.url);
/* if we are to retry, set the result to OK and consider the request /* if we are to retry, set the result to OK and consider the request
as done */ as done */
retry = TRUE; retry = TRUE;

View File

@ -179,7 +179,7 @@ static CURLcode ldap_setup_connection(struct Curl_easy *data,
int rc, proto; int rc, proto;
CURLcode status; CURLcode status;
rc = ldap_url_parse(data->change.url, &lud); rc = ldap_url_parse(data->state.url, &lud);
if(rc != LDAP_URL_SUCCESS) { if(rc != LDAP_URL_SUCCESS) {
const char *msg = "url parsing problem"; const char *msg = "url parsing problem";
status = CURLE_URL_MALFORMAT; status = CURLE_URL_MALFORMAT;
@ -393,9 +393,9 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
connkeep(conn, "OpenLDAP do"); connkeep(conn, "OpenLDAP do");
infof(data, "LDAP local: %s\n", data->change.url); infof(data, "LDAP local: %s\n", data->state.url);
rc = ldap_url_parse(data->change.url, &ludp); rc = ldap_url_parse(data->state.url, &ludp);
if(rc != LDAP_URL_SUCCESS) { if(rc != LDAP_URL_SUCCESS) {
const char *msg = "url parsing problem"; const char *msg = "url parsing problem";
status = CURLE_URL_MALFORMAT; status = CURLE_URL_MALFORMAT;

View File

@ -404,8 +404,8 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done)
/* Referrer */ /* Referrer */
Curl_safefree(data->state.aptr.ref); Curl_safefree(data->state.aptr.ref);
if(data->change.referer && !Curl_checkheaders(data, "Referer")) if(data->state.referer && !Curl_checkheaders(data, "Referer"))
data->state.aptr.ref = aprintf("Referer: %s\r\n", data->change.referer); data->state.aptr.ref = aprintf("Referer: %s\r\n", data->state.referer);
else else
data->state.aptr.ref = NULL; data->state.aptr.ref = NULL;

View File

@ -669,13 +669,13 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
/* /*
* String to set in the HTTP Referer: field. * String to set in the HTTP Referer: field.
*/ */
if(data->change.referer_alloc) { if(data->state.referer_alloc) {
Curl_safefree(data->change.referer); Curl_safefree(data->state.referer);
data->change.referer_alloc = FALSE; data->state.referer_alloc = FALSE;
} }
result = Curl_setstropt(&data->set.str[STRING_SET_REFERER], result = Curl_setstropt(&data->set.str[STRING_SET_REFERER],
va_arg(param, char *)); va_arg(param, char *));
data->change.referer = data->set.str[STRING_SET_REFERER]; data->state.referer = data->set.str[STRING_SET_REFERER];
break; break;
case CURLOPT_USERAGENT: case CURLOPT_USERAGENT:
@ -744,13 +744,13 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
return CURLE_BAD_FUNCTION_ARGUMENT; return CURLE_BAD_FUNCTION_ARGUMENT;
/* append the cookie file name to the list of file names, and deal with /* append the cookie file name to the list of file names, and deal with
them later */ them later */
cl = curl_slist_append(data->change.cookielist, argptr); cl = curl_slist_append(data->state.cookielist, argptr);
if(!cl) { if(!cl) {
curl_slist_free_all(data->change.cookielist); curl_slist_free_all(data->state.cookielist);
data->change.cookielist = NULL; data->state.cookielist = NULL;
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
data->change.cookielist = cl; /* store the list for later use */ data->state.cookielist = cl; /* store the list for later use */
} }
break; break;
@ -1338,14 +1338,14 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
/* /*
* The URL to fetch. * The URL to fetch.
*/ */
if(data->change.url_alloc) { if(data->state.url_alloc) {
/* the already set URL is allocated, free it first! */ /* the already set URL is allocated, free it first! */
Curl_safefree(data->change.url); Curl_safefree(data->state.url);
data->change.url_alloc = FALSE; data->state.url_alloc = FALSE;
} }
result = Curl_setstropt(&data->set.str[STRING_SET_URL], result = Curl_setstropt(&data->set.str[STRING_SET_URL],
va_arg(param, char *)); va_arg(param, char *));
data->change.url = data->set.str[STRING_SET_URL]; data->state.url = data->set.str[STRING_SET_URL];
break; break;
case CURLOPT_PORT: case CURLOPT_PORT:
/* /*
@ -1476,7 +1476,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* that aren't actually in use right now will be pruned immediately. * that aren't actually in use right now will be pruned immediately.
*/ */
data->set.resolve = va_arg(param, struct curl_slist *); data->set.resolve = va_arg(param, struct curl_slist *);
data->change.resolve = data->set.resolve; data->state.resolve = data->set.resolve;
break; break;
case CURLOPT_PROGRESSFUNCTION: case CURLOPT_PROGRESSFUNCTION:
/* /*

View File

@ -1392,20 +1392,20 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
{ {
CURLcode result; CURLcode result;
if(!data->change.url && !data->set.uh) { if(!data->state.url && !data->set.uh) {
/* we can't do anything without URL */ /* we can't do anything without URL */
failf(data, "No URL set!"); failf(data, "No URL set!");
return CURLE_URL_MALFORMAT; return CURLE_URL_MALFORMAT;
} }
/* since the URL may have been redirected in a previous use of this handle */ /* since the URL may have been redirected in a previous use of this handle */
if(data->change.url_alloc) { if(data->state.url_alloc) {
/* the already set URL is allocated, free it first! */ /* the already set URL is allocated, free it first! */
Curl_safefree(data->change.url); Curl_safefree(data->state.url);
data->change.url_alloc = FALSE; data->state.url_alloc = FALSE;
} }
if(!data->change.url && data->set.uh) { if(!data->state.url && data->set.uh) {
CURLUcode uc; CURLUcode uc;
free(data->set.str[STRING_SET_URL]); free(data->set.str[STRING_SET_URL]);
uc = curl_url_get(data->set.uh, uc = curl_url_get(data->set.uh,
@ -1419,7 +1419,7 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
data->state.prefer_ascii = data->set.prefer_ascii; data->state.prefer_ascii = data->set.prefer_ascii;
data->state.list_only = data->set.list_only; data->state.list_only = data->set.list_only;
data->state.httpreq = data->set.method; data->state.httpreq = data->set.method;
data->change.url = data->set.str[STRING_SET_URL]; data->state.url = data->set.str[STRING_SET_URL];
/* Init the SSL session ID cache here. We do it here since we want to do it /* Init the SSL session ID cache here. We do it here since we want to do it
after the *_setopt() calls (that could specify the size of the cache) but after the *_setopt() calls (that could specify the size of the cache) but
@ -1451,11 +1451,11 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
data->state.infilesize = 0; data->state.infilesize = 0;
/* If there is a list of cookie files to read, do it now! */ /* If there is a list of cookie files to read, do it now! */
if(data->change.cookielist) if(data->state.cookielist)
Curl_cookie_loadfiles(data); Curl_cookie_loadfiles(data);
/* If there is a list of host pairs to deal with */ /* If there is a list of host pairs to deal with */
if(data->change.resolve) if(data->state.resolve)
result = Curl_loadhostpairs(data); result = Curl_loadhostpairs(data);
if(!result) { if(!result) {
@ -1585,15 +1585,15 @@ CURLcode Curl_follow(struct Curl_easy *data,
when we get the next URL. We pick the ->url field, which may or may when we get the next URL. We pick the ->url field, which may or may
not be 100% correct */ not be 100% correct */
if(data->change.referer_alloc) { if(data->state.referer_alloc) {
Curl_safefree(data->change.referer); Curl_safefree(data->state.referer);
data->change.referer_alloc = FALSE; data->state.referer_alloc = FALSE;
} }
data->change.referer = strdup(data->change.url); data->state.referer = strdup(data->state.url);
if(!data->change.referer) if(!data->state.referer)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
data->change.referer_alloc = TRUE; /* yes, free this later */ data->state.referer_alloc = TRUE; /* yes, free this later */
} }
} }
} }
@ -1641,13 +1641,13 @@ CURLcode Curl_follow(struct Curl_easy *data,
if(disallowport) if(disallowport)
data->state.allow_port = FALSE; data->state.allow_port = FALSE;
if(data->change.url_alloc) if(data->state.url_alloc)
Curl_safefree(data->change.url); Curl_safefree(data->state.url);
data->change.url = newurl; data->state.url = newurl;
data->change.url_alloc = TRUE; data->state.url_alloc = TRUE;
infof(data, "Issue another request to this URL: '%s'\n", data->change.url); infof(data, "Issue another request to this URL: '%s'\n", data->state.url);
/* /*
* We get here when the HTTP code is 300-399 (and 401). We need to perform * We get here when the HTTP code is 300-399 (and 401). We need to perform
@ -1808,7 +1808,7 @@ CURLcode Curl_retry_request(struct Curl_easy *data, char **url)
} }
infof(data, "Connection died, retrying a fresh connect\ infof(data, "Connection died, retrying a fresh connect\
(retry count: %d)\n", data->state.retrycount); (retry count: %d)\n", data->state.retrycount);
*url = strdup(data->change.url); *url = strdup(data->state.url);
if(!*url) if(!*url)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;

View File

@ -312,16 +312,16 @@ void Curl_freeset(struct Curl_easy *data)
Curl_safefree(data->set.blobs[j]); Curl_safefree(data->set.blobs[j]);
} }
if(data->change.referer_alloc) { if(data->state.referer_alloc) {
Curl_safefree(data->change.referer); Curl_safefree(data->state.referer);
data->change.referer_alloc = FALSE; data->state.referer_alloc = FALSE;
} }
data->change.referer = NULL; data->state.referer = NULL;
if(data->change.url_alloc) { if(data->state.url_alloc) {
Curl_safefree(data->change.url); Curl_safefree(data->state.url);
data->change.url_alloc = FALSE; data->state.url_alloc = FALSE;
} }
data->change.url = NULL; data->state.url = NULL;
Curl_mime_cleanpart(&data->set.mimepost); Curl_mime_cleanpart(&data->set.mimepost);
} }
@ -405,11 +405,11 @@ CURLcode Curl_close(struct Curl_easy **datap)
free(data->req.newurl); free(data->req.newurl);
data->req.newurl = NULL; data->req.newurl = NULL;
if(data->change.referer_alloc) { if(data->state.referer_alloc) {
Curl_safefree(data->change.referer); Curl_safefree(data->state.referer);
data->change.referer_alloc = FALSE; data->state.referer_alloc = FALSE;
} }
data->change.referer = NULL; data->state.referer = NULL;
up_free(data); up_free(data);
Curl_safefree(data->state.buffer); Curl_safefree(data->state.buffer);
@ -1900,27 +1900,27 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
if(data->set.str[STRING_DEFAULT_PROTOCOL] && if(data->set.str[STRING_DEFAULT_PROTOCOL] &&
!Curl_is_absolute_url(data->change.url, NULL, MAX_SCHEME_LEN)) { !Curl_is_absolute_url(data->state.url, NULL, MAX_SCHEME_LEN)) {
char *url = aprintf("%s://%s", data->set.str[STRING_DEFAULT_PROTOCOL], char *url = aprintf("%s://%s", data->set.str[STRING_DEFAULT_PROTOCOL],
data->change.url); data->state.url);
if(!url) if(!url)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
if(data->change.url_alloc) if(data->state.url_alloc)
free(data->change.url); free(data->state.url);
data->change.url = url; data->state.url = url;
data->change.url_alloc = TRUE; data->state.url_alloc = TRUE;
} }
if(!use_set_uh) { if(!use_set_uh) {
char *newurl; char *newurl;
uc = curl_url_set(uh, CURLUPART_URL, data->change.url, uc = curl_url_set(uh, CURLUPART_URL, data->state.url,
CURLU_GUESS_SCHEME | CURLU_GUESS_SCHEME |
CURLU_NON_SUPPORT_SCHEME | CURLU_NON_SUPPORT_SCHEME |
(data->set.disallow_username_in_url ? (data->set.disallow_username_in_url ?
CURLU_DISALLOW_USER : 0) | CURLU_DISALLOW_USER : 0) |
(data->set.path_as_is ? CURLU_PATH_AS_IS : 0)); (data->set.path_as_is ? CURLU_PATH_AS_IS : 0));
if(uc) { if(uc) {
DEBUGF(infof(data, "curl_url_set rejected %s\n", data->change.url)); DEBUGF(infof(data, "curl_url_set rejected %s\n", data->state.url));
return Curl_uc_to_curlcode(uc); return Curl_uc_to_curlcode(uc);
} }
@ -1928,10 +1928,10 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
uc = curl_url_get(uh, CURLUPART_URL, &newurl, 0); uc = curl_url_get(uh, CURLUPART_URL, &newurl, 0);
if(uc) if(uc)
return Curl_uc_to_curlcode(uc); return Curl_uc_to_curlcode(uc);
if(data->change.url_alloc) if(data->state.url_alloc)
free(data->change.url); free(data->state.url);
data->change.url = newurl; data->state.url = newurl;
data->change.url_alloc = TRUE; data->state.url_alloc = TRUE;
} }
uc = curl_url_get(uh, CURLUPART_SCHEME, &data->state.up.scheme, 0); uc = curl_url_get(uh, CURLUPART_SCHEME, &data->state.up.scheme, 0);
@ -1952,8 +1952,8 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
uc = curl_url_set(uh, CURLUPART_SCHEME, "https", 0); uc = curl_url_set(uh, CURLUPART_SCHEME, "https", 0);
if(uc) if(uc)
return Curl_uc_to_curlcode(uc); return Curl_uc_to_curlcode(uc);
if(data->change.url_alloc) if(data->state.url_alloc)
Curl_safefree(data->change.url); Curl_safefree(data->state.url);
/* after update, get the updated version */ /* after update, get the updated version */
uc = curl_url_get(uh, CURLUPART_URL, &url, 0); uc = curl_url_get(uh, CURLUPART_URL, &url, 0);
if(uc) if(uc)
@ -1963,10 +1963,10 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
free(url); free(url);
return Curl_uc_to_curlcode(uc); return Curl_uc_to_curlcode(uc);
} }
data->change.url = url; data->state.url = url;
data->change.url_alloc = TRUE; data->state.url_alloc = TRUE;
infof(data, "Switched from HTTP to HTTPS due to HSTS => %s\n", infof(data, "Switched from HTTP to HTTPS due to HSTS => %s\n",
data->change.url); data->state.url);
} }
} }
#endif #endif
@ -3520,7 +3520,7 @@ static CURLcode create_conn(struct Curl_easy *data,
/************************************************************* /*************************************************************
* Check input data * Check input data
*************************************************************/ *************************************************************/
if(!data->change.url) { if(!data->state.url) {
result = CURLE_URL_MALFORMAT; result = CURLE_URL_MALFORMAT;
goto out; goto out;
} }

View File

@ -1321,8 +1321,6 @@ struct urlpieces {
struct UrlState { struct UrlState {
/* Points to the connection cache */ /* Points to the connection cache */
struct conncache *conn_cache; struct conncache *conn_cache;
int retrycount; /* number of retries on a new connection */
/* buffers to store authentication data in, as parsed from input options */ /* buffers to store authentication data in, as parsed from input options */
struct curltime keeps_speed; /* for the progress meter really */ struct curltime keeps_speed; /* for the progress meter really */
@ -1339,6 +1337,7 @@ struct UrlState {
following not keep sending user+password... This is following not keep sending user+password... This is
strdup() data. strdup() data.
*/ */
int retrycount; /* number of retries on a new connection */
int first_remote_port; /* remote port of the first (not followed) request */ int first_remote_port; /* remote port of the first (not followed) request */
struct Curl_ssl_session *session; /* array of 'max_ssl_sessions' size */ struct Curl_ssl_session *session; /* array of 'max_ssl_sessions' size */
long sessionage; /* number of the most recent session */ long sessionage; /* number of the most recent session */
@ -1408,6 +1407,12 @@ struct UrlState {
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 *referer; /* referer string */
struct curl_slist *cookielist; /* list of cookie files set by
curl_easy_setopt(COOKIEFILE) calls */
struct curl_slist *resolve; /* set to point to the set.resolve list when
this should be dealt with in pretransfer */
#ifndef CURL_DISABLE_HTTP #ifndef CURL_DISABLE_HTTP
size_t trailers_bytes_sent; size_t trailers_bytes_sent;
struct dynbuf trailers_buf; /* a buffer containing the compiled trailing struct dynbuf trailers_buf; /* a buffer containing the compiled trailing
@ -1465,34 +1470,16 @@ struct UrlState {
BIT(use_range); BIT(use_range);
BIT(rangestringalloc); /* the range string is malloc()'ed */ BIT(rangestringalloc); /* the range string is malloc()'ed */
BIT(done); /* set to FALSE when Curl_init_do() is called and set to TRUE BIT(done); /* set to FALSE when Curl_init_do() is called and set to TRUE
when multi_done() is called, to prevent multi_done() to get when multi_done() is called, to prevent multi_done() to get
invoked twice when the multi interface is used. */ invoked twice when the multi interface is used. */
BIT(stream_depends_e); /* set or don't set the Exclusive bit */ BIT(stream_depends_e); /* set or don't set the Exclusive bit */
BIT(previouslypending); /* this transfer WAS in the multi->pending queue */ BIT(previouslypending); /* this transfer WAS in the multi->pending queue */
BIT(cookie_engine); BIT(cookie_engine);
BIT(prefer_ascii); /* ASCII rather than binary */ BIT(prefer_ascii); /* ASCII rather than binary */
BIT(list_only); /* list directory contents */ BIT(list_only); /* list directory contents */
};
/*
* This 'DynamicStatic' struct defines dynamic states that actually change
* values in the 'UserDefined' area, which MUST be taken into consideration
* if the UserDefined struct is cloned or similar. You can probably just
* copy these, but each one indicate a special action on other data.
*/
struct DynamicStatic {
char *url; /* work URL, copied from UserDefined */
char *referer; /* referer string */
struct curl_slist *cookielist; /* list of cookie files set by
curl_easy_setopt(COOKIEFILE) calls */
struct curl_slist *resolve; /* set to point to the set.resolve list when
this should be dealt with in pretransfer */
BIT(url_alloc); /* URL string is malloc()'ed */ BIT(url_alloc); /* URL string is malloc()'ed */
BIT(referer_alloc); /* referer string is malloc()ed */ BIT(referer_alloc); /* referer string is malloc()ed */
BIT(wildcard_resolve); /* Set to true if any resolve change is a BIT(wildcard_resolve); /* Set to true if any resolve change is a wildcard */
wildcard */
}; };
/* /*
@ -1935,7 +1922,6 @@ 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 */
struct DynamicStatic change; /* possibly modified userdefined data */
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"