summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiang Xin <xin.jiang@huawei.com>2016-02-29 23:16:57 +0800
committerJunio C Hamano <gitster@pobox.com>2016-02-29 11:28:39 -0800
commitd445fda44dbf031dccdfd384b2418ea50988a756 (patch)
tree1116afb087a7e8017a8dab95ca66179fdcb60c03
parent372370f1675c2b935fb703665358dd5567641107 (diff)
downloadgit-d445fda44dbf031dccdfd384b2418ea50988a756.tar.gz
http: honor no_http env variable to bypass proxyjx/http-no-proxy
Curl and its families honor several proxy related environment variables: * http_proxy and https_proxy define proxy for http/https connections. * no_proxy (a comma separated hosts) defines hosts bypass the proxy. This command will bypass the bad-proxy and connect to the host directly: no_proxy=* https_proxy=http://bad-proxy/ \ curl -sk https://google.com/ Before commit 372370f (http: use credential API to handle proxy auth...), Environment variable "no_proxy" will take effect if the config variable "http.proxy" is not set. So the following comamnd won't fail if not behind a firewall. no_proxy=* https_proxy=http://bad-proxy/ \ git ls-remote https://github.com/git/git But commit 372370f not only read git config variable "http.proxy", but also read "http_proxy" and "https_proxy" environment variables, and set the curl option using: curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host); This caused "no_proxy" environment variable not working any more. Set extra curl option "CURLOPT_NOPROXY" will fix this issue. Signed-off-by: Jiang Xin <xin.jiang@huawei.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--http.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/http.c b/http.c
index dfc53c1e25..ad3fddf5cc 100644
--- a/http.c
+++ b/http.c
@@ -62,6 +62,7 @@ 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;
@@ -594,6 +595,11 @@ static CURL *get_curl_handle(void)
}
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);