Perform HTTP keep-alive
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 45 46 47
diff --git a/src/transports/http.c b/src/transports/http.c
index ae608ab..6c80020 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -286,7 +286,8 @@ static int on_headers_complete(http_parser *parser)
assert(t->cred);
/* Successfully acquired a credential. */
- return t->parse_error = PARSE_ERROR_REPLAY;
+ t->parse_error = PARSE_ERROR_REPLAY;
+ return 0;
}
}
}
@@ -324,7 +325,8 @@ static int on_headers_complete(http_parser *parser)
t->connected = 0;
s->redirect_count++;
- return t->parse_error = PARSE_ERROR_REPLAY;
+ t->parse_error = PARSE_ERROR_REPLAY;
+ return 0;
}
/* Check for a 200 HTTP status code. */
@@ -382,6 +384,13 @@ static int on_body_fill_buffer(http_parser *parser, const char *str, size_t len)
parser_context *ctx = (parser_context *) parser->data;
http_subtransport *t = ctx->t;
+ /* If our goal is to replay the request (either an auth failure or
+ * a redirect) then don't bother buffering since we're ignoring the
+ * content anyway.
+ */
+ if (t->parse_error == PARSE_ERROR_REPLAY)
+ return 0;
+
if (ctx->buf_size < len) {
giterr_set(GITERR_NET, "Can't fit data in the buffer");
return t->parse_error = PARSE_ERROR_GENERIC;
@@ -456,7 +465,7 @@ static int http_connect(http_subtransport *t)
if (t->connected &&
http_should_keep_alive(&t->parser) &&
- http_body_is_final(&t->parser))
+ t->parse_finished)
return 0;
if (t->socket.socket)