Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
httpclient: no proxy creds in requests if proxy is CONNECT type
  • Loading branch information
implausible committed May 12, 2021
commit 3473a088c645b8361f7b72747610a4a21088a7ed
11 changes: 8 additions & 3 deletions src/transports/httpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,11 @@ static int generate_connect_request(
return git_buf_oom(buf) ? -1 : 0;
}

static bool use_connect_proxy(git_http_client *client)
{
return client->proxy.url.host && !strcmp(client->server.url.scheme, "https");
}

static int generate_request(
git_http_client *client,
git_http_request *request)
Expand Down Expand Up @@ -734,7 +739,8 @@ static int generate_request(
git_buf_printf(buf, "Expect: 100-continue\r\n");

if ((error = apply_server_credentials(buf, client, request)) < 0 ||
(error = apply_proxy_credentials(buf, client, request)) < 0)
(!use_connect_proxy(client) &&
(error = apply_proxy_credentials(buf, client, request)) < 0))
return error;

if (request->custom_headers) {
Expand Down Expand Up @@ -1027,8 +1033,7 @@ static int http_client_connect(
reset_parser(client);

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

if (use_proxy) {
if (!client->proxy_connected || !client->keepalive ||
Expand Down