On kqueue, backend EOF may be reported while the H1 mux still has response
body bytes in h1c->ibuf. With a flow-controlled H2 or H3 consumer,
h1_fastfwd() can forward only part of those bytes, then observe read0 while
h1m->curr_len is still nonzero. It reports a truncated response and aborts
the client stream even though the remaining bytes are already in memory.
In the affected FreeBSD/H3 workload, 16 KiB responses reached the client
as 16,066 bytes and curl reported a partial transfer.
Classify read0 in this fast-forward path only after h1c->ibuf is empty.
Keep fast forwarding active so a later consumer window update can drain the
buffer. The existing EOS/EOI and genuine-truncation decisions then run with
the correct remaining message length.
A VTest reproducer holds the H2 window closed until the backend closes,
then opens it in steps to force read0 with buffered H1 input. It fails on
unpatched macOS and FreeBSD kqueue builds and passes with the fix. The same
fix passes on the affected 3.4.7 source and current 3.4.9 maintenance source.
A genuinely short Content-Length response still forwards exactly the sent
bytes and resets the H2 stream.
This patch should fix the issue #3612. It must be backported as far as 3.0.
}
}
- if (conn_xprt_read0_pending(h1c->conn)) {
+ /* Buffered input must be forwarded before judging the message at EOF. */
+ if (!b_data(&h1c->ibuf) && conn_xprt_read0_pending(h1c->conn)) {
se_fl_set(h1s->sd, SE_FL_EOS);
TRACE_STATE("report EOS to SE", H1_EV_STRM_RECV, h1c->conn, h1s);
if (h1m->state >= H1_MSG_DONE || !(h1m->flags & H1_MF_XFER_LEN)) {