diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2014-07-31 18:39:58 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2014-08-15 11:12:42 -0400 |
commit | 40867266bf964ed6acb2344e594e0c49106c3c67 (patch) | |
tree | 940106a0371b90bdd4bc415be8da749006461e26 | |
parent | adcdeb36b0892c61832eb9add0b5cd6e9610e064 (diff) | |
download | libgit2-40867266bf964ed6acb2344e594e0c49106c3c67.tar.gz |
Perform HTTP keep-alive
-rw-r--r-- | src/transports/http.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/transports/http.c b/src/transports/http.c index ae608ab3d..6c80020c1 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) |