summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-03-09 17:24:16 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2019-06-10 19:58:22 +0100
commit9050c69c0ea4ee5dc8e55ff12736ecd2425c9dc0 (patch)
treec292502ab38f3fc5ccd17695c8eec3da2de4cf9a
parent956ba48bdd488d4e22dd5a468df952765b8c9824 (diff)
downloadlibgit2-9050c69c0ea4ee5dc8e55ff12736ecd2425c9dc0.tar.gz
http: examine keepalive status at message end
We cannot examine the keep-alive status of the http parser in `http_connect`; it's too late and the critical information about whether keep-alive is supported has been destroyed. Per the documentation for `http_should_keep_alive`: > If http_should_keep_alive() in the on_headers_complete or > on_message_complete callback returns 0, then this should be > the last message on the connection. Query then and set the state.
-rw-r--r--src/transports/http.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/transports/http.c b/src/transports/http.c
index bd3f812c0..453b910cd 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -108,6 +108,7 @@ typedef struct {
int parse_error;
int error;
unsigned parse_finished : 1,
+ keepalive : 1,
replay_count : 4;
} http_subtransport;
@@ -571,6 +572,7 @@ static int on_message_complete(http_parser *parser)
http_subtransport *t = ctx->t;
t->parse_finished = 1;
+ t->keepalive = http_should_keep_alive(parser);
return 0;
}
@@ -615,6 +617,7 @@ static void clear_parser_state(http_subtransport *t)
t->last_cb = NONE;
t->parse_error = 0;
t->parse_finished = 0;
+ t->keepalive = 0;
git_buf_dispose(&t->parse_header_name);
git_buf_init(&t->parse_header_name, 0);
@@ -929,9 +932,7 @@ static int http_connect(http_subtransport *t)
void *cb_payload;
int error;
- if (t->connected &&
- http_should_keep_alive(&t->parser) &&
- t->parse_finished)
+ if (t->connected && t->keepalive && t->parse_finished)
return 0;
if ((error = load_proxy_config(t)) < 0)