Skip to content
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

Don't set the status code if the response has started #45664

Merged
merged 1 commit into from
Dec 19, 2022

Conversation

davidfowl
Copy link
Member

@davidfowl davidfowl commented Dec 19, 2022

  • Middleware that writes then ends up at the terminal middleware ends up throwing an exception. This change doesn't set the status code if the response has started.
  • Added a test

PS: I was answering a question on Stackoverflow and noticed this behavior.

- Middleware that writes then ends up at the terminal middleware ends up throwing an exception. This change doesn't set the status code if the response has started.
- Added a test
@davidfowl davidfowl merged commit c94c3b1 into main Dec 19, 2022
@davidfowl davidfowl deleted the davidfowl/skip-status-code branch December 19, 2022 08:28
@ghost ghost added this to the 8.0-preview1 milestone Dec 19, 2022
@Tratcher
Copy link
Member

This should throw a specific InvalidOperationException instead. A middleware should not call next if it's produced a response. You'd have the same problem if any other middleware was next and tried to produce its own response.

@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 25, 2023
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