]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: http-fetch: don't report pseudo-headers in TCP mode
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 7 Oct 2026 14:35:59 +0000 (16:35 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 12 Oct 2026 13:46:14 +0000 (15:46 +0200)
In TCP mode, HTTP sample fetches parse the raw request found in the channel
buffer using h1_headers_to_hdr_list() before converting it to HTX. But the
H1_MF_NO_PHDR flag was not set, so the ":method" and ":path" pseudo-headers
produced by the parser were added as regular headers to the HTX
message. Thus, for "GET /x HTTP/1.1" with a single Host header, req.hdr_cnt
returns 3, req.hdrs and req.hdr_names contain ":method" and ":path", and
req.hdr(:path) returns the URI, unlike in HTTP mode. It also consumes two
header slots, so that requests with 99 or 100 headers make the fetches fail
in TCP mode while they are accepted in HTTP mode.

Let's set H1_MF_NO_PHDR for this parsing.

This was introduced by commit ef453ed9b ("MINOR: http_fetch: Add
smp_prefetch_htx") in 1.9-dev7. It may be backported to all stable versions.

src/http_fetch.c

index af5dc3c07f4ffbf7095653566ea6a5f0818c06f0..83f2ff5ee682c630bf1f28c2e86e6229c58f576f 100644 (file)
@@ -273,6 +273,8 @@ struct htx *smp_prefetch_htx(struct sample *smp, struct channel *chn, struct che
                        b_slow_realign(buf, trash.area, 0);
 
                h1m_init_req(&h1m);
+               /* pseudo-headers must not be turned into regular headers */
+               h1m.flags |= H1_MF_NO_PHDR;
                ret = h1_headers_to_hdr_list(b_head(buf), b_stop(buf),
                                             hdrs, sizeof(hdrs)/sizeof(hdrs[0]), &h1m, &h1sl);
                if (ret <= 0) {