From: Junio C Hamano Date: Mon, 24 Apr 2017 05:07:44 +0000 (-0700) Subject: Merge branch 'sr/http-proxy-configuration-fix' X-Git-Tag: v2.13.0-rc1~35 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/6b51cb61812c11915dbcc1d6daeee60ac77297de?hp=6a2c2f8d34fa1e8f3bb85d159d354810ed63692e 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 --- diff --git a/http.c b/http.c index 8d94e2c63a..7a168ed5a8 100644 --- a/http.c +++ b/http.c @@ -836,8 +836,14 @@ static CURL *get_curl_handle(void) } } - if (curl_http_proxy) { - curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy); + if (curl_http_proxy && curl_http_proxy[0] == '\0') { + /* + * Handle case with the empty http.proxy value here to keep + * common code clean. + * NB: empty option disables proxying at all. + */ + curl_easy_setopt(result, CURLOPT_PROXY, ""); + } else if (curl_http_proxy) { #if LIBCURL_VERSION_NUM >= 0x071800 if (starts_with(curl_http_proxy, "socks5h")) curl_easy_setopt(result, @@ -861,6 +867,9 @@ static CURL *get_curl_handle(void) strbuf_release(&url); } + if (!proxy_auth.host) + die("Invalid proxy URL '%s'", curl_http_proxy); + curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host); #if LIBCURL_VERSION_NUM >= 0x071304 var_override(&curl_no_proxy, getenv("NO_PROXY"));