]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: response parser: Drop previous response's pool immediately when parsing...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 4 Feb 2017 14:40:41 +0000 (15:40 +0100)
committerGitLab <gitlab@git.dovecot.net>
Wed, 15 Feb 2017 12:00:16 +0000 (14:00 +0200)
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.

src/lib-http/http-response-parser.c

index 0f70092590d641bcb1ef4da4786d21a3af7874a1..a9e4ff2aa5da6c99b0f7a15ed67537411c76f6a1 100644 (file)
@@ -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:
@@ -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