From 693cd1679361828adb281ece01508cfdaec64e12 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 10 Jan 2024 23:20:09 +0100 Subject: [PATCH] http_proxy: a blank CURLOPT_USERAGENT should not be used in CONNECT Extended test 80 to verify this. Reported-by: Stefan Eissing Fixes #12680 Closes #12681 --- lib/http_proxy.c | 4 ++-- tests/data/test80 | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/http_proxy.c b/lib/http_proxy.c index 8e1832581d..113c43a413 100644 --- a/lib/http_proxy.c +++ b/lib/http_proxy.c @@ -131,8 +131,8 @@ CURLcode Curl_http_proxy_create_CONNECT(struct httpreq **preq, goto out; } - if(!Curl_checkProxyheaders(data, cf->conn, STRCONST("User-Agent")) - && data->set.str[STRING_USERAGENT]) { + if(!Curl_checkProxyheaders(data, cf->conn, STRCONST("User-Agent")) && + data->set.str[STRING_USERAGENT] && *data->set.str[STRING_USERAGENT]) { result = Curl_dynhds_cadd(&req->headers, "User-Agent", data->set.str[STRING_USERAGENT]); if(result) diff --git a/tests/data/test80 b/tests/data/test80 index 21d9fd2ea5..c6aa05b173 100644 --- a/tests/data/test80 +++ b/tests/data/test80 @@ -53,7 +53,7 @@ http-proxy HTTP 1.0 CONNECT with proxytunnel and proxy+host Basic authentication -http://test.%TESTNUMBER:%HTTPPORT/we/want/that/page/%TESTNUMBER -p --proxy1.0 %HOSTIP:%PROXYPORT --user iam:myself --proxy-user youare:yourself +http://test.%TESTNUMBER:%HTTPPORT/we/want/that/page/%TESTNUMBER -p --proxy1.0 %HOSTIP:%PROXYPORT --user iam:myself --proxy-user youare:yourself -A "" proxy @@ -67,7 +67,6 @@ proxy CONNECT test.%TESTNUMBER:%HTTPPORT HTTP/1.0 Host: test.%TESTNUMBER:%HTTPPORT Proxy-Authorization: Basic eW91YXJlOnlvdXJzZWxm -User-Agent: curl/%VERSION Proxy-Connection: Keep-Alive @@ -75,7 +74,6 @@ Proxy-Connection: Keep-Alive GET /we/want/that/page/%TESTNUMBER HTTP/1.1 Host: test.%TESTNUMBER:%HTTPPORT Authorization: Basic aWFtOm15c2VsZg== -User-Agent: curl/%VERSION Accept: */*