urldata: move cookiehost to struct SingleRequest

To make it scoped for the single request appropriately.

Reported-by: Muhamad Arga Reksapati

Verify with libtest 2504: a custom Host *disabled* on reused handle
This commit is contained in:
Daniel Stenberg 2026-04-14 08:51:44 +02:00
parent 0567e72168
commit 2aad1df87f
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
9 changed files with 159 additions and 12 deletions

View file

@ -2081,8 +2081,8 @@ static CURLcode http_set_aptr_host(struct Curl_easy *data)
if(colon)
*colon = 0; /* The host must not include an embedded port number */
}
curlx_free(aptr->cookiehost);
aptr->cookiehost = cookiehost;
curlx_free(data->req.cookiehost);
data->req.cookiehost = cookiehost;
}
#endif
@ -2577,8 +2577,8 @@ static CURLcode http_cookies(struct Curl_easy *data,
if(data->cookies && data->state.cookie_engine) {
bool okay;
const char *host = data->state.aptr.cookiehost ?
data->state.aptr.cookiehost : data->conn->host.name;
const char *host = data->req.cookiehost ?
data->req.cookiehost : data->conn->host.name;
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
result = Curl_cookie_getlist(data, data->conn, &okay, host, &list);
if(!result && okay) {
@ -3578,8 +3578,8 @@ static CURLcode http_header_s(struct Curl_easy *data,
if(v) {
/* If there is a custom-set Host: name, use it here, or else use
* real peer hostname. */
const char *host = data->state.aptr.cookiehost ?
data->state.aptr.cookiehost : conn->host.name;
const char *host = data->req.cookiehost ?
data->req.cookiehost : conn->host.name;
const bool secure_context = Curl_secure_context(conn, host);
CURLcode result;
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);