Repository navigation
Implement RFC 9931 §8 for HTTP/1.1 CONNECT in Kestrel - #67929
Merged
Merged
Conversation
Per RFC 9931 Section 8, an HTTP/1.1 server that rejects a CONNECT request must close the connection. Disable keep-alive when the request method is CONNECT, the protocol is HTTP/1.1, and the final status code is >= 300. Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Kestrel’s HTTP/1.1 behavior to comply with RFC 9931 §8 by ensuring that rejected CONNECT requests (final status ≥ 300) do not keep the underlying connection alive.
Changes:
- Disable keep-alive for HTTP/1.1
CONNECTresponses with final status code ≥ 300. - Add functional tests asserting rejected CONNECT closes the HTTP/1.1 connection (including when the request sends
Connection: keep-alive). - Add a functional test asserting accepted (2xx) CONNECT does not force connection close and allows subsequent requests on the same connection.
Show a summary per file
| File | Description |
|---|---|
| src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.cs | Disables keep-alive for rejected HTTP/1.1 CONNECT responses per RFC 9931 §8. |
| src/Servers/Kestrel/test/InMemory.FunctionalTests/ResponseTests.cs | Adds regression tests covering rejected/accepted CONNECT connection-lifetime behavior on HTTP/1.1. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 1
Comment on lines
+1256
to
+1263
| // Close the connection when rejecting an HTTP/1.1 CONNECT request. | ||
| // See https://www.rfc-editor.org/rfc/rfc9931#section-8. | ||
| if (_httpVersion == Http.HttpVersion.Http11 && | ||
| Method == HttpMethod.Connect && | ||
| StatusCode >= StatusCodes.Status300MultipleChoices) | ||
| { | ||
| DisableKeepAlive(ConnectionEndReason.ResponseNoKeepAlive); | ||
| } |
DeagleGross
approved these changes
Jul 21, 2026
MihaZupan
approved these changes
Jul 21, 2026
This was referenced Jul 22, 2026
github-actions Bot
added a commit
that referenced
this pull request
Jul 25, 2026
…rMode_Top_AppendKeepsViewportStable The test has shown intermittent failures in CI across multiple builds against unrelated PRs (#67742, #67929). Associated issue: #aw_qgridtop Co-authored-by: Copilot <[email protected]>
ilonatommy
pushed a commit
that referenced
this pull request
Jul 27, 2026
…rMode_Top_AppendKeepsViewportStable (#68018) The test has shown intermittent failures in CI across multiple builds against unrelated PRs (#67742, #67929). Associated issue: #68017 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <[email protected]>
3 of 4 tasks
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.
Per RFC 9931 §8, an HTTP/1.1 server that rejects a
CONNECTrequest must close the connection. Kestrel currently keeps it open. This change disables keep-alive when the method isCONNECT, the version is HTTP/1.1, and the final status is ≥ 300. HTTP/2, HTTP/3, and accepted (2xx) CONNECTs are unaffected.