Improper handling of empty POST requests.
jankyjames opened this issue · comments
When POST
ing to a route without a Content-Type
but the route is configured to consume some Content-Type
, If there is also no body in that request, the Content-Type
validation finishes without error, but candidates remains 0 resulting in the Accept
handling to process.
I think normally this would be fine since it seems like there is an additional check for empty POST requests here to return a valid 415
, but some clients like Postman automatically sets the header Content-Length
to "0"
resulting in this check getting skipped and defaulting to 406
when that isn't the issue.
I suggest either updating the check at line 158 from method == http.MethodPatch) && length == "" {
to
method == http.MethodPatch) && (length == "" || length == "0") {
or
method == http.MethodPatch) && httpRequest.ContentLength == 0 {
The method in question is here
If you think this fixes the issue I'd be happy to submit a PR to fix this :) Just let me know!
If you think this fixes the issue I'd be happy to submit a PR to fix this :) Just let me know!
@JamesDChilds can you propose a PR? thx!