summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-04-07 17:55:23 +0900
committerEdward Thomson <ethomson@edwardthomson.com>2019-06-10 19:58:22 +0100
commit005b5bc28794624305d82597e1072726e189827e (patch)
tree79846eb447e6724e90953828076cb01e50e0de13
parentd171fbee16d7ca7868c1d2d85f19d6dcaf31f8ee (diff)
downloadlibgit2-005b5bc28794624305d82597e1072726e189827e.tar.gz
http: reconnect to proxy on connection close
When we're issuing a CONNECT to a proxy, we expect to keep-alive to the proxy. However, during authentication negotiations, the proxy may close the connection. Reconnect if the server closes the connection.
-rw-r--r--src/transports/http.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/transports/http.c b/src/transports/http.c
index f29d09b75..c28c5fcd8 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -992,8 +992,12 @@ replay:
t->request_count++;
- if (auth_replay)
- goto replay;
+ if (auth_replay) {
+ if (t->keepalive && t->parse_finished)
+ goto replay;
+
+ return PARSE_ERROR_REPLAY;
+ }
if ((error = git_tls_stream_wrap(out, proxy_stream, t->server.url.host)) == 0)
error = stream_connect(*out, &t->server.url,
@@ -1043,6 +1047,7 @@ static int http_connect(http_subtransport *t)
void *cb_payload;
int error;
+auth_replay:
if (t->connected && t->keepalive && t->parse_finished)
return 0;
@@ -1099,8 +1104,15 @@ static int http_connect(http_subtransport *t)
proxy_stream = stream;
stream = NULL;
- if ((error = proxy_connect(&stream, proxy_stream, t)) < 0)
+ error = proxy_connect(&stream, proxy_stream, t);
+
+ if (error == PARSE_ERROR_REPLAY) {
+ git_stream_close(proxy_stream);
+ git_stream_free(proxy_stream);
+ goto auth_replay;
+ } else if (error < 0) {
goto on_error;
+ }
}
t->proxy.stream = proxy_stream;