Commit 9050c69c by Edward Thomson

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.
parent 956ba48b
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment