httpclient: no proxy creds in requests if proxy is CONNECT type

parent 049618ce
...@@ -681,6 +681,11 @@ static int generate_connect_request( ...@@ -681,6 +681,11 @@ static int generate_connect_request(
return git_buf_oom(buf) ? -1 : 0; 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( static int generate_request(
git_http_client *client, git_http_client *client,
git_http_request *request) git_http_request *request)
...@@ -734,7 +739,8 @@ static int generate_request( ...@@ -734,7 +739,8 @@ static int generate_request(
git_buf_printf(buf, "Expect: 100-continue\r\n"); git_buf_printf(buf, "Expect: 100-continue\r\n");
if ((error = apply_server_credentials(buf, client, request)) < 0 || 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; return error;
if (request->custom_headers) { if (request->custom_headers) {
...@@ -1027,8 +1033,7 @@ static int http_client_connect( ...@@ -1027,8 +1033,7 @@ static int http_client_connect(
reset_parser(client); reset_parser(client);
/* Reconnect to the proxy if necessary. */ /* Reconnect to the proxy if necessary. */
use_proxy = client->proxy.url.host && use_proxy = use_connect_proxy(client);
!strcmp(client->server.url.scheme, "https");
if (use_proxy) { if (use_proxy) {
if (!client->proxy_connected || !client->keepalive || if (!client->proxy_connected || !client->keepalive ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment