summaryrefslogtreecommitdiff
path: root/lib/transfer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/transfer.c')
-rw-r--r--lib/transfer.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index a07c7af8c..c7b3596eb 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -1531,6 +1531,21 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
Curl_http2_init_state(&data->state);
}
+ /*
+ * 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;
}