]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: h1: forget a previous pass' results when parsing headers only
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 7 Oct 2026 14:04:50 +0000 (16:04 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 16 Oct 2026 17:10:27 +0000 (19:10 +0200)
In H1_MF_HDRS_ONLY mode, which is used for FCGI responses (no start-line),
h1_headers_to_hdr_list() always parses the headers again from the beginning
when it's called again after an incomplete parsing. But unlike the normal
restart path, the flags and lengths found during the previous pass were not
reset. So when the headers of an FCGI response are received in several
parts, the content-length found in the first part is seen as a duplicate
during the second pass and the header is dropped. The response is then
forwarded to the client without content-length, close-delimited, and the
client connection is closed. Similarly, "transfer-encoding: chunked" is seen
twice and reported as an error (ignored in this mode).

Let's reset the flags as on a regular restart, keeping the version and
method flags set by the caller in this mode, as well as the lengths.

This patch should be backported to all supported versions.

src/h1.c

index 12c70d0b16316e72ef86db624aa67fa91233edc1..2cef677ac8bbf4d2fb5dbfea18e0232d8be9af7e 100644 (file)
--- a/src/h1.c
+++ b/src/h1.c
@@ -448,7 +448,8 @@ int h1_headers_to_hdr_list(char *start, const char *stop,
 
        if (h1m->flags & H1_MF_HDRS_ONLY) {
                state = H1_MSG_HDR_FIRST;
-               h1m->next = 0;
+               h1m->flags &= (H1_MF_RESTART_MASK|H1_MF_VER_11);
+               h1m->curr_len = h1m->body_len = h1m->next = 0;
        }
        else {
                state = h1m->state;