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.