Skip to content

Commit

Permalink
lib-http: response parser: Drop previous response's pool immediately …
Browse files Browse the repository at this point in the history
…when parsing continues.

Prevously, it would only do that when the first byte of the next response was received.
This prevents wasting memory when no response is being parsed.
  • Loading branch information
stephanbosch authored and GitLab committed Feb 15, 2017
1 parent 88ead42 commit c177bc7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib-http/http-response-parser.c
Expand Up @@ -146,7 +146,6 @@ static int http_response_parse(struct http_response_parser *parser)
*/
switch (parser->state) {
case HTTP_RESPONSE_PARSE_STATE_INIT:
http_response_parser_restart(parser);
parser->state = HTTP_RESPONSE_PARSE_STATE_VERSION;
/* fall through */
case HTTP_RESPONSE_PARSE_STATE_VERSION:
Expand Down Expand Up @@ -313,6 +312,9 @@ int http_response_parse_next(struct http_response_parser *parser,
return ret;
}

if (parser->state == HTTP_RESPONSE_PARSE_STATE_INIT)
http_response_parser_restart(parser);

/* RFC 7230, Section 3:
HTTP-message = start-line
Expand Down

0 comments on commit c177bc7

Please sign in to comment.