fix(http1): discard content-length in client responses that also have transfer-encoding - #4181
Open
dylanpulver wants to merge 1 commit into
Open
Conversation
… transfer-encoding The server side of this was fixed in hyperium#4124. The client side of the same parse was left alone: Client::decoder took the head by shared reference, so it could not remove the canceled content-length, and it had no way to signal that the connection should not be reused. Client::decoder now takes the head by mutable reference and reports whether it removed a content-length, and Client::parse clears keep_alive in that case.
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.
#4124 fixed this for
Server::parse.Client::parsehas the same shape and was not touched, so a response carrying bothtransfer-encodingandcontent-lengthis framed correctly but keeps the canceledcontent-length, and the connection is still reused. Both header orders, unlike the server.Against a raw server replying
content-length: 10+transfer-encoding: chunkedwith a 5-byte chunked body, on master:With the change: header gone,
ready()false, second request opens a new connection.Client::decodertook the head by shared reference, so it could not remove the header and had no way to say the connection should not be reused. It now takes&mutand reports whether it removed a content-length;Client::parseclearskeep_alivein that case. The existing client test asserted only.decode— the new assertions are the three-part form #4124 introduced on the server side.Deliberately not changed: 1xx/204/304 and responses to HEAD return before the transfer-encoding branch, so a
content-lengththere is left alone. On a HEAD response it is metadata about the body a GET would return rather than framing, and removing it would lose information.cargo test --features fullgreen, same 308 passing as master.cargo fmt --checkclean.cargo clippy --features full -- -D warningsfails on unmodified master here too (unknown lint: clippy::unused_async_trait_impl, my clippy is 0.1.97), so I changed nothing for it.AI disclosure: prepared with AI assistance (Claude Opus 5,
claude-opus-5). The output above is from the commands as shown.