-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Throw BadHttpRequestException in HttpSys #24213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw BadHttpRequestException in HttpSys #24213
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. It better matches Kestrel's and IIS in-proc's behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only covers half of #20688 so far. The other half is to catch the exception and return that status code. That would probobly happen here:
aspnetcore/src/Servers/HttpSys/src/RequestProcessing/RequestContext.cs
Lines 274 to 292 in e9d989f
catch (Exception ex) | |
{ | |
Logger.LogError(LoggerEventIds.RequestProcessError, ex, "ProcessRequestAsync"); | |
application.DisposeContext(context, ex); | |
if (Response.HasStarted) | |
{ | |
// HTTP/2 INTERNAL_ERROR = 0x2 https://tools.ietf.org/html/rfc7540#section-7 | |
// Otherwise the default is Cancel = 0x8. | |
SetResetCode(2); | |
Abort(); | |
} | |
else | |
{ | |
// We haven't sent a response yet, try to send a 500 Internal Server Error | |
Response.Headers.IsReadOnly = false; | |
Response.Trailers.IsReadOnly = false; | |
Response.Headers.Clear(); | |
Response.Trailers.Clear(); | |
SetFatalResponse(500); |
Better. There should be existing tests for this scenario that you can update. |
Nice. You're still missing test coverage for the new catch behavior. It's probably a combination of one of the tests you updated and something like this: aspnetcore/src/Servers/HttpSys/test/FunctionalTests/ServerTests.cs Lines 197 to 213 in 8b79720
|
Thanks |
Fixes #20688