1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-24 17:18:48 -05:00

pretransfer: setup the User-Agent header here

... and not in the connection setup, as for multiplexed transfers the
connection setup might be skipped and then the transfer would end up
without the set user-agent!

Reported-by: Flameborn on github
Assisted-by: Andrey Gursky
Assisted-by: Jay Satiro
Assisted-by: Mike Gelfand
Fixes #6312
Closes #6417
This commit is contained in:
Daniel Stenberg 2021-01-05 14:30:21 +01:00
parent 80c5a838ce
commit 0936ecd0ee
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 14 additions and 14 deletions

View File

@ -1495,6 +1495,20 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
Curl_hsts_loadcb(data, data->hsts); Curl_hsts_loadcb(data, data->hsts);
} }
/*
* Set user-agent. Used for HTTP, but since we can attempt to tunnel
* basically anything through a http proxy we can't limit this based on
* protocol.
*/
if(data->set.str[STRING_USERAGENT]) {
Curl_safefree(data->state.aptr.uagent);
data->state.aptr.uagent =
aprintf("User-Agent: %s\r\n", data->set.str[STRING_USERAGENT]);
if(!data->state.aptr.uagent)
return CURLE_OUT_OF_MEMORY;
}
data->req.headerbytecount = 0;
return result; return result;
} }

View File

@ -3942,20 +3942,6 @@ CURLcode Curl_setup_conn(struct connectdata *conn,
lingering set from a previous invoke */ lingering set from a previous invoke */
conn->bits.proxy_connect_closed = FALSE; conn->bits.proxy_connect_closed = FALSE;
#endif #endif
/*
* Set user-agent. Used for HTTP, but since we can attempt to tunnel
* basically anything through a http proxy we can't limit this based on
* protocol.
*/
if(data->set.str[STRING_USERAGENT]) {
Curl_safefree(data->state.aptr.uagent);
data->state.aptr.uagent =
aprintf("User-Agent: %s\r\n", data->set.str[STRING_USERAGENT]);
if(!data->state.aptr.uagent)
return CURLE_OUT_OF_MEMORY;
}
data->req.headerbytecount = 0;
#ifdef CURL_DO_LINEEND_CONV #ifdef CURL_DO_LINEEND_CONV
data->state.crlf_conversions = 0; /* reset CRLF conversion counter */ data->state.crlf_conversions = 0; /* reset CRLF conversion counter */