pretransfer: setup the User-Agent header here 59/266659/1 accepted/tizen/base/20211121.213041 submit/tizen_base/20211118.011723
authorSeonah Moon <seonah1.moon@samsung.com>
Wed, 17 Nov 2021 03:08:41 +0000 (12:08 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Wed, 17 Nov 2021 03:08:43 +0000 (12:08 +0900)
... 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

https://github.com/curl/curl/issues/6312
https://github.com/curl/curl/pull/6417

Change-Id: I91d196cf08bd96c0534621ad7eae9eb73a004f21

lib/transfer.c
lib/url.c
packaging/curl.spec

index a07c7af..c7b3596 100644 (file)
@@ -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;
 }
 
index 625dbfe..82d14ac 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -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 */
index be0757a..80e43cc 100644 (file)
@@ -1,7 +1,7 @@
 Name:       curl
 Summary:    A utility for getting files from remote servers (FTP, HTTP, and others)
 Version:    7.73.0
-Release:    1
+Release:    2
 Group:      Applications/Internet
 License:    MIT
 URL:        http://curl.haxx.se/