Return 500 for invalid transfer encoding on non-body responses - #68901
Open
zeohhh wants to merge 2 commits into
Open
Return 500 for invalid transfer encoding on non-body responses#68901zeohhh wants to merge 2 commits into
zeohhh wants to merge 2 commits into
Conversation
zeohhh
requested review from
BrennanConroy,
SamMonoRT and
halter73
as code owners
August 29, 2026 07:16
Author
|
@dotnet-policy-service agree |
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.
Return a 500 response instead of terminating the connection when an
application completes with an invalid Transfer-Encoding header on a
non-body response.
Description
HttpProtocol.ProduceStartmarked the response asHeadersCommittedbefore calling
CreateResponseHeaders.When header validation detected an invalid
Transfer-Encodingafter theapplication had completed, Kestrel attempted to replace the response with
a 500 response. This failed because the response was already considered
started, causing the connection to terminate without sending a response.
This change moves the transition to
HeadersCommitteduntil after responseheader creation and validation succeeds, while keeping it before
Output.WriteResponseHeaders.A functional regression test covers GET responses with status codes 204,
205, and 304, as well as HEAD responses. Existing explicit response-start
behavior remains unchanged.
Testing
src/Servers/Kestrel/test.Fixes #4382