Merge branch 'jx/http-no-proxy'
authorJunio C Hamano <gitster@pobox.com>
Thu, 10 Mar 2016 18:56:43 +0000 (10:56 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 10 Mar 2016 18:56:43 +0000 (10:56 -0800)
* jx/http-no-proxy:
http: honor no_http env variable to bypass proxy

1  2 
http.c
diff --combined http.c
index 1d5e3bbd11ae0e7dc0e682d3914e07cc13a0ce14,ad3fddf5cc48a3e28f082564913e31ecd6b92bd8..69da4454d8f754598d0316d0e1cb34870aba2b8e
--- 1/http.c
--- 2/http.c
+++ b/http.c
  #include "gettext.h"
  #include "transport.h"
  
 +#if LIBCURL_VERSION_NUM >= 0x070a08
 +long int git_curl_ipresolve = CURL_IPRESOLVE_WHATEVER;
 +#else
 +long int git_curl_ipresolve;
 +#endif
  int active_requests;
  int http_is_verbose;
  size_t http_post_buffer = 16 * LARGE_PACKET_MAX;
@@@ -62,14 -57,12 +62,15 @@@ static const char *ssl_key
  #if LIBCURL_VERSION_NUM >= 0x070908
  static const char *ssl_capath;
  #endif
 +#if LIBCURL_VERSION_NUM >= 0x072c00
 +static const char *ssl_pinnedkey;
 +#endif
  static const char *ssl_cainfo;
  static long curl_low_speed_limit = -1;
  static long curl_low_speed_time = -1;
  static int curl_ftp_no_epsv;
  static const char *curl_http_proxy;
+ static const char *curl_no_proxy;
  static const char *http_proxy_authmethod;
  static struct {
        const char *name;
@@@ -95,7 -88,6 +96,7 @@@ static int curl_save_cookies
  struct credential http_auth = CREDENTIAL_INIT;
  static int http_proactive_auth;
  static const char *user_agent;
 +static int curl_empty_auth;
  
  #if LIBCURL_VERSION_NUM >= 0x071700
  /* Use CURLOPT_KEYPASSWD as is */
@@@ -308,31 -300,14 +309,31 @@@ static int http_options(const char *var
        if (!strcmp("http.useragent", var))
                return git_config_string(&user_agent, var, value);
  
 +      if (!strcmp("http.emptyauth", var)) {
 +              curl_empty_auth = git_config_bool(var, value);
 +              return 0;
 +      }
 +
 +      if (!strcmp("http.pinnedpubkey", var)) {
 +#if LIBCURL_VERSION_NUM >= 0x072c00
 +              return git_config_pathname(&ssl_pinnedkey, var, value);
 +#else
 +              warning(_("Public key pinning not supported with cURL < 7.44.0"));
 +              return 0;
 +#endif
 +      }
 +
        /* Fall back on the default ones */
        return git_default_config(var, value, cb);
  }
  
  static void init_curl_http_auth(CURL *result)
  {
 -      if (!http_auth.username)
 +      if (!http_auth.username) {
 +              if (curl_empty_auth)
 +                      curl_easy_setopt(result, CURLOPT_USERPWD, ":");
                return;
 +      }
  
        credential_fill(&http_auth);
  
@@@ -524,10 -499,6 +525,10 @@@ static CURL *get_curl_handle(void
  #if LIBCURL_VERSION_NUM >= 0x070908
        if (ssl_capath != NULL)
                curl_easy_setopt(result, CURLOPT_CAPATH, ssl_capath);
 +#endif
 +#if LIBCURL_VERSION_NUM >= 0x072c00
 +      if (ssl_pinnedkey != NULL)
 +              curl_easy_setopt(result, CURLOPT_PINNEDPUBLICKEY, ssl_pinnedkey);
  #endif
        if (ssl_cainfo != NULL)
                curl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo);
                }
  
                curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);
+ #if LIBCURL_VERSION_NUM >= 0x071304
+               var_override(&curl_no_proxy, getenv("NO_PROXY"));
+               var_override(&curl_no_proxy, getenv("no_proxy"));
+               curl_easy_setopt(result, CURLOPT_NOPROXY, curl_no_proxy);
+ #endif
        }
        init_curl_proxy_auth(result);
  
@@@ -854,14 -830,10 +860,14 @@@ struct active_request_slot *get_active_
        curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
        curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);
        curl_easy_setopt(slot->curl, CURLOPT_RANGE, NULL);
 +
 +#if LIBCURL_VERSION_NUM >= 0x070a08
 +      curl_easy_setopt(slot->curl, CURLOPT_IPRESOLVE, git_curl_ipresolve);
 +#endif
  #ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
        curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);
  #endif
 -      if (http_auth.password)
 +      if (http_auth.password || curl_empty_auth)
                init_curl_http_auth(slot->curl);
  
        return slot;