Skip to content

Commit 6b51cb6

Browse files
committed
Merge branch 'sr/http-proxy-configuration-fix'
"http.proxy" set to an empty string is used to disable the usage of proxy. We broke this early last year. * sr/http-proxy-configuration-fix: http: fix the silent ignoring of proxy misconfiguraion http: honor empty http.proxy option to bypass proxy
2 parents 6a2c2f8 + ae51d91 commit 6b51cb6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

http.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,14 @@ static CURL *get_curl_handle(void)
836836
}
837837
}
838838

839-
if (curl_http_proxy) {
840-
curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
839+
if (curl_http_proxy && curl_http_proxy[0] == '\0') {
840+
/*
841+
* Handle case with the empty http.proxy value here to keep
842+
* common code clean.
843+
* NB: empty option disables proxying at all.
844+
*/
845+
curl_easy_setopt(result, CURLOPT_PROXY, "");
846+
} else if (curl_http_proxy) {
841847
#if LIBCURL_VERSION_NUM >= 0x071800
842848
if (starts_with(curl_http_proxy, "socks5h"))
843849
curl_easy_setopt(result,
@@ -861,6 +867,9 @@ static CURL *get_curl_handle(void)
861867
strbuf_release(&url);
862868
}
863869

870+
if (!proxy_auth.host)
871+
die("Invalid proxy URL '%s'", curl_http_proxy);
872+
864873
curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);
865874
#if LIBCURL_VERSION_NUM >= 0x071304
866875
var_override(&curl_no_proxy, getenv("NO_PROXY"));

0 commit comments

Comments
 (0)