Repository navigation
fix(mux-h2): drop trailer fields of a Content-Length-framed message - #1731
Merged
Merged
Conversation
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 30, 2026 14:19
FlorentinDUBOIS
force-pushed
the
fix/h2-h1-length-framed-trailers
branch
3 times, most recently
from
October 1, 2026 13:59
42f4ec1 to
8bd77c3
Compare
FlorentinDUBOIS
force-pushed
the
fix/h2-h1-length-framed-trailers
branch
from
October 1, 2026 15:52
8bd77c3 to
342c269
Compare
HTTP/1.1 carries a trailer section only with chunked coding (RFC 9112 section 6.3, 7.1), but kawa's H1 serializer wrote the trailer fields and a closing empty line of an H2 message framed by content-length after the body, for a request to an H1 backend and for a response to an H1 client. ConnectionH1::writable now drops such a trailer block before writing (RFC 9110 section 6.5.1) and counts it in h2.trailers_dropped_content_length. pkawa::handle_trailer keeps validating, eliding and queuing the block, so an H2 peer still receives these trailers. Correct the comments and the metric description that said these trailers were already dropped. Closes #1730 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/h2-h1-length-framed-trailers
branch
from
October 1, 2026 19:19
342c269 to
64402cf
Compare
Signed-off-by: Florentin Dubois <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1730
Change
H2→H1: drop the trailer fields of a Content-Length-framed message instead of writing them after the body.
HTTP/1.1 carries a trailer section only with chunked transfer coding (RFC 9112 §7.1.2), and a message framed by Content-Length ends with its last body byte (RFC 9112 §6.3). RFC 9110 §6.5 lets a recipient discard trailers.
ConnectionH1::drop_length_framed_trailers(lib/src/protocol/mux/h1.rs) runs inConnectionH1::writablebefore kawa's H1prepare. For aBodySize::Lengthmessage whose queue ends with a trailer block, it removes the trailer fields and clearsend_headeron the closing flags, so nothing is written after the body. This covers requests to an H1 backend and responses to an H1 client.warn!and incrementsh2.trailers_dropped_content_lengthat the write.pkawa::handle_trailerstill validates, elides and queues the block, so H2 peers keep these trailers and theh2.trailer.*_elidedcounters are unchanged.doc/configure.mdmetric row,lib/src/protocol/mux/LIFECYCLE.md§8.4, CHANGELOG (Unreleased, Security).#1724 (last chunk before H2 trailers on a chunked H1 body) is merged; this branch is rebased on it.
Tests
a_length_framed_message_writes_no_trailer_to_an_h1_peer(h1.rs): request and response, with one trailer field and with none; H1 bytes are exactlyhello.a_length_framed_header_section_is_not_taken_for_trailers(h1.rs).a_length_framed_trailer_block_reaches_an_h2_peer(converter.rs): DATA, then HEADERS with END_STREAM holding the trailer field.handle_trailer_filters_and_keeps_a_length_framed_block(pkawa.rs): elision counters fire for a length-framed block.test_h2_length_framed_request_trailers_keep_h1_backend_framing(e2e): the backend bytes are split by HTTP/1.1 framing, and the byte after the body starts the next request line.Validation
-D warnings,cargo test -p sozu-lib --all-features, fuzz build, and the 4check_doc_citations.pymodes all exit 0.protocol_pair_matrixandh2_security_header_injectionpass.trailer: 21 passed, 1 failed,test_h1_trailer_field_limit_exceeded_split_closes_backend. That failure is pre-existing onmain(H1→H1, chunked body) and is being fixed separately.