# [PATCH v3 1/4] http: support proxies that needs authentication

2 messages from 2012-03-05 to 2012-03-05. Participants: Nelson Benitez Leon, Junio C Hamano.
Thread: https://gitlist.dev/t/29837

## Nelson Benitez Leon, 2012-03-05 15:16

Subject: [PATCH v3 1/4] http: support proxies that needs authentication
Message-ID: <4F54D8BB.4080305@seap.minhap.es>
URL: https://gitlist.dev/e/4F54D8BB.4080305%40seap.minhap.es

```
When the proxy server specified by the http.proxy configuration or
the http_proxy environment variable requires authentication, git
failed to connect to the proxy, because we did not configure the
cURL handle with CURLOPT_PROXYAUTH.

When a proxy is in use, and you tell git that the proxy requires
authentication by having username in the http.proxy configuration,
an extra request needs to be made to the proxy to find out what
authentication method it supports, as this patch uses CURLAUTH_ANY
to let the library pick the most secure method supported by the
proxy server.

The extra round-trip adds extra latency, but relieves the user
from the burden to configure a specific authentication method.  If
it becomes problem, a later patch could add a configuration option
to specify what method to use, but let's start simple for the time
being.

Signed-off-by: Nelson Benitez Leon <nbenitezl@gmail.com>
---
 http.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/http.c b/http.c
index 0ffd79c..8ac8eb6 100644
--- a/http.c
+++ b/http.c
@@ -295,8 +295,10 @@ static CURL *get_curl_handle(void)
 	if (curl_ftp_no_epsv)
 		curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);
 
-	if (curl_http_proxy)
+	if (curl_http_proxy) {
 		curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
+		curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
+	}
 
 	return result;
 }
-- 
1.7.7.6

```

## Junio C Hamano, 2012-03-05 17:30

Subject: Re: [PATCH v3 1/4] http: support proxies that needs authentication
Message-ID: <7vzkbv0xbk.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vzkbv0xbk.fsf%40alter.siamese.dyndns.org
In-Reply-To: <4F54D8BB.4080305@seap.minhap.es>

```
Thanks; I think I already have the same change.

```
