summaryrefslogtreecommitdiff
path: root/lib/transfer.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-01-05 14:30:21 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-01-05 23:46:32 +0100
commit0936ecd0ee5e3e28c098fefc9e2c0e6847cb7a82 (patch)
tree952f377574f2eae130669b839a0bf46dd2b2ccda /lib/transfer.c
parent80c5a838ce2ad79a067f010aae55e94b878c639d (diff)
downloadcurl-0936ecd0ee5e3e28c098fefc9e2c0e6847cb7a82.tar.gz
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
Diffstat (limited to 'lib/transfer.c')
-rw-r--r--lib/transfer.c14
1 files changed, 14 insertions, 0 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;
}