diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-01-05 14:30:21 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-01-05 14:30:21 +0100 |
commit | ae092a9cab82ec79d2d20855c49b4df06df5100a (patch) | |
tree | 8eb50301d78c4a09f6d5355a05c7b23f3a6ba73c | |
parent | 56b32b5d7570c7eb4275bfe513af6a758f1dfe94 (diff) | |
download | curl-ae092a9cab82ec79d2d20855c49b4df06df5100a.tar.gz |
pretransfer: setup the User-Agent header herebagder/init-user-agent
... 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
Fixes #6312
-rw-r--r-- | lib/transfer.c | 14 | ||||
-rw-r--r-- | lib/url.c | 14 |
2 files changed, 14 insertions, 14 deletions
diff --git a/lib/transfer.c b/lib/transfer.c index 7b5a0516d..baf305fe1 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -1495,6 +1495,20 @@ CURLcode Curl_pretransfer(struct Curl_easy *data) 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; } @@ -3942,20 +3942,6 @@ CURLcode Curl_setup_conn(struct connectdata *conn, lingering set from a previous invoke */ conn->bits.proxy_connect_closed = FALSE; #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 data->state.crlf_conversions = 0; /* reset CRLF conversion counter */ |