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
Allow parsing empty request bodies #895
Conversation
Disallowing empty bodies was an optimization for parsing `application/json` requests (since JSON bodies are not valid if they are empty). However, now that the ContentTypeParser can be used to parse other content types, this has become a bug.
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.
Given that the original issue was about a DELETE, can you add a test for that as well?
LGTM on the rest of the code.
And what happens if an empty |
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.
What happens if the request has an empty body with a content-length header?
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.
Sorry my bad.
LGTM
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 with @mcollina nit
@mcollina Added.
@jsumners The same thing as any other request with invalid JSON: JSON.parse() will throw.
@allevo If the |
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
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
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Disallowing empty bodies was an optimization for parsing
application/json
requests (since JSON bodies are not valid if they are empty). However, now that the ContentTypeParser can be used to parse other content types, this has become a bug.Fixes #894
Checklist
npm run test
andnpm run benchmark