Skip to content

Commit dd61399

Browse files
Nelson Benitez Leongitster
authored andcommitted
http: support proxies that require authentication
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 222433e commit dd61399

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

http.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,10 @@ static CURL *get_curl_handle(void)
295295
if (curl_ftp_no_epsv)
296296
curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);
297297

298-
if (curl_http_proxy)
298+
if (curl_http_proxy) {
299299
curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
300+
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
301+
}
300302

301303
return result;
302304
}

0 commit comments

Comments
 (0)