Skip to content

Commit 3473a08

Browse files
committed
httpclient: no proxy creds in requests if proxy is CONNECT type
1 parent 049618c commit 3473a08

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/transports/httpclient.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,11 @@ static int generate_connect_request(
681681
return git_buf_oom(buf) ? -1 : 0;
682682
}
683683

684+
static bool use_connect_proxy(git_http_client *client)
685+
{
686+
return client->proxy.url.host && !strcmp(client->server.url.scheme, "https");
687+
}
688+
684689
static int generate_request(
685690
git_http_client *client,
686691
git_http_request *request)
@@ -734,7 +739,8 @@ static int generate_request(
734739
git_buf_printf(buf, "Expect: 100-continue\r\n");
735740

736741
if ((error = apply_server_credentials(buf, client, request)) < 0 ||
737-
(error = apply_proxy_credentials(buf, client, request)) < 0)
742+
(!use_connect_proxy(client) &&
743+
(error = apply_proxy_credentials(buf, client, request)) < 0))
738744
return error;
739745

740746
if (request->custom_headers) {
@@ -1027,8 +1033,7 @@ static int http_client_connect(
10271033
reset_parser(client);
10281034

10291035
/* Reconnect to the proxy if necessary. */
1030-
use_proxy = client->proxy.url.host &&
1031-
!strcmp(client->server.url.scheme, "https");
1036+
use_proxy = use_connect_proxy(client);
10321037

10331038
if (use_proxy) {
10341039
if (!client->proxy_connected || !client->keepalive ||

0 commit comments

Comments
 (0)