Repository navigation
fix(http1): drop Content-Length when a response also has Transfer-Encoding - #4264
Merged
seanmonstar merged 1 commit intoNov 13, 2026
Conversation
…oding The HTTP/1 server decoder already removes Content-Length when Transfer-Encoding is present. The client decoder preferred Transfer-Encoding for the body length, but still exposed both headers. RFC 7230 §3.3.3 says Transfer-Encoding overrides Content-Length. Remove the Content-Length header from parsed responses so callers cannot treat it as authoritative. Closes hyperium#4263
Member
|
duplicate of #4181. |
Member
|
Actually, I much prefer the simplicity of this fix over the other PR 🤓 |
seanmonstar
approved these changes
Nov 13, 2026
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.
The HTTP/1 server decoder already removes
Content-LengthwhenTransfer-Encodingis present. The client decoder already usedTransfer-Encodingfor the body length, but still left both headers on the response.RFC 7230 §3.3.3 says
Transfer-EncodingoverridesContent-Length. This removesContent-Lengthfrom parsed HTTP/1 responses in that case, so callers cannot treat it as authoritative.test_decoder_responsenow covers both header orders, including a 5-byte chunked body advertised withContent-Length: 100000as in #4263.Closes #4263