-
Notifications
You must be signed in to change notification settings - Fork 10.3k
StatusCodePagesMiddleware: Improving response started verification #46576
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
Conversation
@@ -26,21 +26,26 @@ public StatusCodePagesOptions() | |||
|
|||
if (context.HttpContext.RequestServices.GetService<IProblemDetailsService>() is { } problemDetailsService) | |||
{ | |||
await problemDetailsService.WriteAsync(new () | |||
await problemDetailsService.WriteAsync(new() | |||
{ | |||
HttpContext = context.HttpContext, | |||
ProblemDetails = { Status = statusCode } | |||
}); | |||
} | |||
|
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.
Checking the content-length and content-type is weird, just make the original code an else block.
else | |
{ | |
context.HttpContext.Response.ContentType = "text/plain"; | |
await context.HttpContext.Response.WriteAsync(body); | |
} |
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.
Oh, just saw your comment on the issue... I'll revisit this next week, but I still don't think we want to rely on checking content-length or content-type to determine the presence of a buffered body.
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.
Yeah! I don't like it as well but since we were using it already, I decided to suggest it. I tried a repro to see if I can find something reliable but as I mentioned, in the issue, I was not able to repro.
Closing this PR to work on a more appropriated fix. |
Hi @brunolins16. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
Fix #45678