Strip Transfer-Encoding when Content-Length is present in HTTPEncoder#3583
Merged
fabianfett merged 4 commits intoapple:mainfrom May 6, 2026
Merged
Conversation
### Motivation When correctlyFrameTransportHeaders() detected a Content-Length header, it returned .contentLength without removing any existing Transfer-Encoding header. ### Changes - Remove Transfer-Encoding headers, if a Content-Length header is present ### Result NIO sends either a `Content-Length` header or a `Transfer-Encoding` header, but not both.
fabianfett
commented
Apr 30, 2026
| "1000_getHandlers": 8050, | ||
| "1000_getHandlers_sync": 37, | ||
| "1000_reqs_1_conn": 26350, | ||
| "1000_reqs_1_conn": 27400, |
Member
Author
There was a problem hiding this comment.
looks like we are running into a cow now.
Lukasa
approved these changes
May 6, 2026
weissi
reviewed
May 6, 2026
| return .neither | ||
| case .yes: | ||
| if headers.contains(name: "content-length") { | ||
| headers.remove(name: "transfer-encoding") |
Member
There was a problem hiding this comment.
why are we trying to fix up illegal HTTP? Originally (as shown by the crash tests) the idea was that this is "programmer error". Kinda defensible but also maybe not super helpful for proxy authors.
But now we're trying to fix up broken HTTP? Why don't we reject using an error?
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.
Strip Transfer-Encoding when Content-Length is present in HTTPEncoder
Motivation
When
correctlyFrameTransportHeaders()detected aContent-Lengthheader, it returned.contentLengthwithout removing any existingTransfer-Encodingheader.Changes
Transfer-Encodingheader, if aContent-Lengthheader is presentResult
NIO sends either a
Content-Lengthheader or aTransfer-Encodingheader, but not both.