]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: mux-h1: support the H2 preface received in several segments
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 1 Dec 2026 12:57:54 +0000 (13:57 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 3 Dec 2026 12:41:06 +0000 (13:41 +0100)
commit27327db883ef2c7752ad2dd617ab321c77e7e342
tree9fc04f19f885322694e2eb434f5e60b8695d9260
parent07b1d29974f177ab7215fec1f6835e0b6e6b8a5a
BUG/MINOR: mux-h1: support the H2 preface received in several segments

When a cleartext HTTP/2 prior-knowledge client connects to an HTTP/1
listener, the connection is upgraded to H2 if the first request matches the
H2 connection preface. But the check with b_isteq() only succeeds when the
whole 24-byte preface is already buffered. When the preface is received in
two or more segments and the first one holds 18 to 23 bytes ("PRI *
HTTP/2.0\r\n\r\n" possibly with the beginning of "SM"), b_isteq() reports a
partial match (0), the data are parsed as a complete but invalid H1 request
and the client receives a 400 instead of the upgrade.

The fix detects the partial match by truncating the preface to the number of
buffered bytes, and then waits for more data instead of parsing it as
H1. The full preface still upgrades, anything that is not a strict prefix of
the preface is parsed as H1 exactly as before, and the http-request timeout
still applies while waiting.

This patch could be backported to all supported versions.
src/mux_h1.c