Merge branch 'sr/http-proxy-configuration-fix'
authorJunio C Hamano <gitster@pobox.com>
Mon, 24 Apr 2017 05:07:44 +0000 (22:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Apr 2017 05:07:44 +0000 (22:07 -0700)
"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

1  2 
http.c

diff --combined http.c
--- 1/http.c
--- 2/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,
                        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;
        }