-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Indicate if the request has a body #24984
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
Why don't we add a feature? |
Like |
Adding a new required feature is a breaking change. For this to be reliable we need to know if the server can even detect empty bodies before asking if the body is empty. If |
Make it a |
c7b1b74
to
a95d38d
Compare
How's that? @davidfowl @halter73? If you like it I'll do IIS and TestServer also. |
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
e04556e
to
e59cc53
Compare
I'll follow-up for IIS in a later PR, I can't get those tests to run locally. |
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.
Maybe file an issue to verify our servers have consistent behavior when trying to read the request body of a Connection: Upgrade
request.
b925615
to
1c59c18
Compare
Hello @Tratcher! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
#24175 In HTTP/2 and later the app can't tell from examining request headers if there's a request body. Content-Length is optional and
Transfer-Encoding: chunked
is prohibited. The only way for the app to know if there's a body is to try to read it. That's not great for scenarios like YARP that need to act differently if there's a request body, but want to avoid reading it as long as possible.For back-compat Http.Sys/IIS adds a fake
Transfer-Encoding: chunked
header to HTTP/2 requests that have bodies and no Content-Length.Edit: I've reworked this as a first class feature and property
bool? HttpRequest.CanHaveBody
. Returns null for not implemented, false if the server is sure there's no body, or true if there might be a body. I say might because with HTTP/2 or chunked the body could still end up being empty, you just don't know that up front.Done:
Transfer-Encoding
header is missing. #21677, automatically including the chunked header for HTTP/1.1 bodies.TODO:
The API: