From: Willy Tarreau Date: Tue, 3 Nov 2026 17:49:11 +0000 (+0100) Subject: MINOR: h1: indicate the trailers state to h1_parse_msg_tlrs() X-Git-Tag: v3.5-dev11~37 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=e8399b5fd5628b53d4c2e138c7d67ac00b50e169;p=haproxy.git MINOR: h1: indicate the trailers state to h1_parse_msg_tlrs() 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. --- diff --git a/src/h1_htx.c b/src/h1_htx.c index 11ad7b2e6..33bea0e7b 100644 --- a/src/h1_htx.c +++ b/src/h1_htx.c @@ -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 safely points to the