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=-c 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 --- 6b51cb61812c11915dbcc1d6daeee60ac77297de diff --combined http.c index 8d94e2c63a,82664ddddb..7a168ed5a8 --- a/http.c +++ b/http.c @@@ -836,8 -836,14 +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 +867,9 @@@ 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")); @@@ -1366,9 -1375,9 +1375,9 @@@ static int handle_curl_result(struct sl * FAILONERROR it is lost, so we can give only the numeric * status code. */ - snprintf(curl_errorstr, sizeof(curl_errorstr), - "The requested URL returned error: %ld", - results->http_code); + xsnprintf(curl_errorstr, sizeof(curl_errorstr), + "The requested URL returned error: %ld", + results->http_code); } if (results->curl_result == CURLE_OK) { @@@ -1410,8 -1419,8 +1419,8 @@@ int run_one_slot(struct active_request_ { slot->results = results; if (!start_active_slot(slot)) { - snprintf(curl_errorstr, sizeof(curl_errorstr), - "failed to start HTTP request"); + xsnprintf(curl_errorstr, sizeof(curl_errorstr), + "failed to start HTTP request"); return HTTP_START_FAILED; }