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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
diff --git a/src/transports/http.c b/src/transports/http.c
index f29d09b..c28c5fc 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;