Re: [PATCH 2/3] http: try standard proxy env vars when http.proxy config option is not set
From: Jeff King <hidden>
Date: 2016-06-15 22:53:10
On Tue, Feb 28, 2012 at 01:54:34PM +0100, Nelson Benitez Leon wrote:
quoted hunk ↗ jump to hunk
diff --git a/http.c b/http.c index 8ac8eb6..79cbe50 100644 --- a/http.c +++ b/http.c@@ -295,6 +295,16 @@ static CURL *get_curl_handle(void) if (curl_ftp_no_epsv) curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0); + if (!curl_http_proxy) { + const char *env_proxy; + env_proxy = getenv("HTTP_PROXY"); + if (!env_proxy) { + env_proxy = getenv("http_proxy"); + } + if (env_proxy) { + curl_http_proxy = xstrdup(env_proxy); + } + }
Usually we would prefer environment variables to config. So that: $ git config http.proxy foo $ HTTP_PROXY=bar git fetch would use "bar" as the proxy, not "foo". But your code above would prefer "foo", right?
From reading Thomas's messages, I think there is a slight complication
in that right now curl is respecting $http_proxy, and it is probably
letting git's http.proxy overwrite (though I didn't check). If that is
the case, then that is IMHO a bug that should be fixed. So the rationale
for this patch would be three-fold:
1. Support HTTP_PROXY, which curl does not accept.
2. Fix the precedence of environment variables over config.
3. By handling the proxy variables ourselves, we have more flexibility
in handling the authentication.
-Peff