Add tests for empty POST and content-length #4612
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This relates to...
A discrepancy in behavior about empty POST request, when enabling or not enabling H2.
See #4594.
Rationale
This adds two tests:
According to RFC 9110:
So, the behavior of Undici sending a
0
Content-Length
on empty POST request when H2 is not enabled is recommended by the RFC, while its behavior of sending no Content-Length on such requests when H2 is enabled does not match the recommendation. (It is still compliant since that is a "SHOULD", not a "MUST".)Whether this should be changed or not, I do not know. Is there a good reason for this behavior with H2?
For your information, some servers cannot receive empty POST requests without a Content-Length. That is the case of Internet Information Server (IIS), the default web server of Windows OSes. Windows OSes underlying
http.sys
rejects such requests with a 411 Length required response.Changes
Add two tests to demonstrate the current behavior of Undici.
Features
N/A
Bug Fixes
N/A
Breaking Changes and Deprecations
None
Status