From 049618cebe5848e8c5456c32fd136aefdeecccc6 Mon Sep 17 00:00:00 2001 From: Tyler Ang-Wanek Date: Fri, 30 Apr 2021 15:11:54 -0700 Subject: [PATCH 1/2] httpclient: git_http_client_skip_body should drain socket of body --- src/transports/httpclient.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transports/httpclient.c b/src/transports/httpclient.c index d3975746b73..4ba6da01720 100644 --- a/src/transports/httpclient.c +++ b/src/transports/httpclient.c @@ -1503,7 +1503,7 @@ int git_http_client_skip_body(git_http_client *client) "unexpected data handled in callback"); error = -1; } - } while (!error); + } while (error >= 0 && client->state != DONE); if (error < 0) client->connected = 0; From 3473a088c645b8361f7b72747610a4a21088a7ed Mon Sep 17 00:00:00 2001 From: Tyler Ang-Wanek Date: Wed, 12 May 2021 11:48:23 -0700 Subject: [PATCH 2/2] httpclient: no proxy creds in requests if proxy is CONNECT type --- src/transports/httpclient.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/transports/httpclient.c b/src/transports/httpclient.c index 4ba6da01720..ba86184dfc8 100644 --- a/src/transports/httpclient.c +++ b/src/transports/httpclient.c @@ -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) @@ -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) { @@ -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 ||