Skip to content

fix(mux-h1): write no last chunk or trailers after the head of a response without a body - #1766

Merged
FlorentinDUBOIS merged 2 commits into
mainfrom
fix/h1-no-body-response-trailers
Oct 2, 2026
Merged

FlorentinDUBOIS merged 2 commits into
mainfrom
fix/h1-no-body-response-trailers

Conversation

@FlorentinDUBOIS

@FlorentinDUBOIS FlorentinDUBOIS commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

A response to HEAD, a 204 or a 304 ends with its header section on HTTP/1.1 (RFC 9112 §6.3). When an H2 backend sent its HEADERS without END_STREAM and without content-length, the response was framed as chunked and the end of its stream (a trailer HEADERS frame or an empty DATA frame) was written to an H1 client as a last chunk, the trailer fields and an empty line after the head.

ConnectionH1::writable now clears the end-of-body framing and drops the trailer block of such a response before writing (RFC 9110 §6.5.1), and counts a dropped block in the new h2.trailers_dropped_no_body. A stream ended by a trailer HEADERS frame or an empty DATA frame then writes nothing after the head. Left as is: the Transfer-Encoding: chunked field added to such a head, and DATA carrying a payload on such a response, which is still written after the head.

Covered by unit tests in lib/src/protocol/mux/h1.rs and by the e2e test test_h2_bodiless_response_trailers_keep_h1_client_framing. Documented in lib/src/protocol/mux/LIFECYCLE.md §8.4, doc/configure.md and CHANGELOG.md.

Fixes #1761

@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the fix/h1-no-body-response-trailers branch from 113c158 to 8d14110 Compare October 1, 2026 15:45
@FlorentinDUBOIS FlorentinDUBOIS changed the title fix(mux-h1): write nothing after the head of a response without a body fix(mux-h1): write no last chunk or trailers after the head of a response without a body Oct 1, 2026
A response to HEAD, a 204 or a 304 ends with its header section on
HTTP/1.1 (RFC 9112 section 6.3), but when an H2 backend sent its HEADERS
without END_STREAM and without content-length, the response was framed
as chunked and the end of its stream, a trailer HEADERS frame or an
empty DATA frame, was written to an H1 client as a last chunk, the
trailer fields and an empty line after the head, read by a keep-alive
client as the start of the next response.

ConnectionH1::writable now clears the end-of-body framing and drops the
trailer block of such a response before writing (RFC 9110 section
6.5.1), and counts a dropped block in h2.trailers_dropped_no_body.

Closes #1761

Signed-off-by: Florentin Dubois <[email protected]>
The end-of-body framing and trailer block of a response to HEAD, a 204
or a 304 are cleared for a stream ended by a trailer HEADERS frame or
an empty DATA frame. DATA carrying a payload on such a response is
still written after the head; name it as a known gap.

Refs #1761

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the fix/h1-no-body-response-trailers branch from 16511a7 to 7ba9128 Compare October 2, 2026 00:01
@FlorentinDUBOIS
FlorentinDUBOIS merged commit ecac9f4 into main Oct 2, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(mux-h1): bytes written after the head of a response without a body to an H1 client

1 participant