Repository navigation
Drop trailers on HTTP/1.0, and never use the Trailer field to choose framing. - #50
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… chunked bodies may have trailers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the `base-http1` readme. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…th versions, and that `may_have_trailers` selects chunked framing.
…ing its trailers, so imperative uploads keep their wire format.
… test that an HTTP/1.0 tunnel refuses trailers.
Trailer field only as a hint.Trailer field to choose framing.
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.
HTTP/1.0 now drops trailers instead of refusing messages whose bodies may have them. An HTTP/1.1 request of known length is sent with
Content-Lengthand drops its trailers too, while responses stay chunked whenever their body may have trailers. ATrailerfield is now treated only as a hint and no longer affects framing. Incoming bodies reportmay_have_trailers()only when they are chunked.HTTP/1.0 has no chunked framing, so it cannot carry trailers, and HTTP semantics (RFC 9110 §6.5.1) let them be discarded. Until now, the HTTP/1.0 request writer refused any body whose
may_have_trailers()was true, with "trailers require HTTP/1.1 chunked framing". EveryBodyReaderreports true, so a streamed request could never be sent over HTTP/1.0. A response to an HTTP/1.0 client failed when its body actually produced trailers.Outgoing messages
Content-Lengthand its trailers are dropped, through bothwrite_requestand imperativebegin_request/write_frame.Content-Length: 0.Content-Lengtheven when the body may have trailers, which are dropped after validation, instead of being chunked. This coverswrite_requestwith a body such asBodyReader::with_length, andbegin_requestwith acontent_length. Request trailers are rare, a client MUST NOT sendTransfer-Encodingunless it knows the server handles HTTP/1.1 (RFC 9112 §6.1), and length-requiring servers answer 411. Bodyless GETs and known-length uploads therefore keep main's wire format, and an imperative request withcontent_lengthand aTrailerfield, which main chunked, now completes with its trailer dropped instead of failing. HTTP/1.1 requests of unknown length are still chunked and keep their trailers.Content-Lengthor close-delimited bodies report no trailers and keepContent-Length; HEAD, 204 and 304 take no framing.The shared
BodyEncodergainsdiscard_trailers, which the request writer enables for every non-chunked request and the response writer enables for HTTP/1.0 output that isn't a tunnel.write_bodynow takes the encoder.The
TrailerfieldNobody knows ahead of time whether a message will have trailers. The
Trailerfield is only a SHOULD hint (gRPC, for example, omits it), so it no longer decides anything:For responses,
may_have_trailers()alone decides framing; for requests, a known length does.Incoming bodies
On the receiving side, only chunked bodies report
may_have_trailers(). That rules out HTTP/1.0 bodies,Content-Lengthbodies and close-delimited bodies. This already held, and new codec tests now pin it for both the server and the client, along with keeping received trailers out of the header fields. HTTP/1.0 messages withTransfer-Encodingwere already refused on read, and the lane is not reused.design/http1-trailers.mdrecords this model, anddesign/fixtures.md,design/implementation.md,design/proposal.mdand thebase-http1readme are updated to match.Tests
http10_trailers_are_dropped) covers that case by checking that the connection serves a further request.base-http-fixtures. #49 also editscrates/fixtures. After this lands, Add spawned server contexts, split raw peers and a two-way streaming case tobase-http-fixtures. #49 can drop its private no-trailers upload wrapper.🤖 Generated with Claude Code