]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: h1: indicate the trailers state to h1_parse_msg_tlrs()
authorWilly Tarreau <w@1wt.eu>
Tue, 3 Nov 2026 17:49:11 +0000 (18:49 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 4 Nov 2026 21:45:32 +0000 (22:45 +0100)
In order to parse H1 trailers, h1_parse_msg_tlrs() builds a local dummy
h1m that sets H1_MF_HDRS_ONLY and calls h1_headers_to_hdr_list() which
directly jumps to plain headers parsing. However, this latter function
has no way to adjust its error processing on header or trailer because
the information regarding the fact that headers or trailers are being
parsed isn't present. Currently this is not a problem but it will become
in order to refine error processing to have separate rules for headers
and trailers.

This patch sets the dummy h1m's state to H1_MSG_TRAILERS so that the
called function can safely rely on it. All other callers pass a real
message with a valid state, so it will be possible to check h1m->state
during error processing to figure if the function is in the process of
parsing trailers or headers.

src/h1_htx.c

index 11ad7b2e6970778f14a1b1c9cecf8122d967baf7..33bea0e7b7c699e11f5bbb0d77628341f8d191bc 100644 (file)
@@ -1035,6 +1035,7 @@ int h1_parse_msg_tlrs(struct h1m *h1m, struct htx *dsthtx,
        if (b_head(srcbuf) + b_data(srcbuf) > b_wrap(srcbuf))
                b_slow_realign_ofs(srcbuf, trash.area, 0);
 
+       tlr_h1m.state = H1_MSG_TRAILERS;
        tlr_h1m.flags = (H1_MF_NO_PHDR|H1_MF_HDRS_ONLY);
        tlr_h1m.err_pos = h1m->err_pos;
        /* The buffer was realigned above, so <b_stop()> safely points to the