Skip to content

Implement RFC 9931 §8 for HTTP/1.1 CONNECT in Kestrel - #67929

Merged
BrennanConroy merged 1 commit into
mainfrom
brennanconroy/didactic-robot
Jul 21, 2026
Merged

BrennanConroy merged 1 commit into
mainfrom
brennanconroy/didactic-robot

Conversation

@BrennanConroy

Copy link
Copy Markdown
Member

Per RFC 9931 §8, an HTTP/1.1 server that rejects a CONNECT request must close the connection. Kestrel currently keeps it open. This change disables keep-alive when the method is CONNECT, the version is HTTP/1.1, and the final status is ≥ 300. HTTP/2, HTTP/3, and accepted (2xx) CONNECTs are unaffected.

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]>
Copilot AI review requested due to automatic review settings July 20, 2026 22:55
@BrennanConroy
BrennanConroy requested a review from halter73 as a code owner July 20, 2026 22:55
@BrennanConroy BrennanConroy added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Jul 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CONNECT responses 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);
}
@BrennanConroy
BrennanConroy merged commit d117bfd into main Jul 21, 2026
36 checks passed
@BrennanConroy
BrennanConroy deleted the brennanconroy/didactic-robot branch July 21, 2026 20:20
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants