Skip to content

Conversation

@adityamandaleeka
Copy link
Member

Change the behavior in Kestrel's request processing logic so that bad requests are only logged as errors if the connection has not been aborted. This reduces noise in the logs for common client errors.

We already expose bad request information via Microsoft.AspNetCore.Server.Kestrel.BadRequests so anyone who is interested in seeing all of this already has a mechanism for doing so, and we don't show scary "fail" messages to people who don't care.

This issue has been a source of great frustration for years now (#23949), and generally, there's nothing the server dev can do when there's an unexpected client behavior (e.g. aborting a connection before completing a request) so this seems like a sane default.

Fix #23949

Copilot AI review requested due to automatic review settings February 13, 2025 02:38
@ghost ghost added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Feb 13, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

@JamesNK
Copy link
Member

JamesNK commented Feb 13, 2025

Unit tests? One where the message is logged (open connection) and another that verifies it isn't (closed connection)

@adityamandaleeka
Copy link
Member Author

Added a new test for the aborted connection scenario and piggybacked on an existing one for the other case where we want to keep the message the same.

@adityamandaleeka adityamandaleeka merged commit ed01b60 into dotnet:main Feb 20, 2025
24 of 27 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview3 milestone Feb 20, 2025
@sergeant05
Copy link

Is this change included in asp.net 8 ?
@adityamandaleeka

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.

Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Unexpected end of request content.

4 participants