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
Incorrect use of 406 Not Acceptable for incorrect content type #492
Comments
thank you for reporting this. |
i have a test that reproduces the problem now
|
with
|
emicklei
added a commit
that referenced
this issue
May 25, 2022
emicklei
added a commit
that referenced
this issue
Jun 4, 2022
pr merged |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a case where I am using JSON (for request/response). I am making a request that in fact includes an empty body. Technically of course, an empty body is not JSON. However the behavior I am seeing seems incorrect.
Consider the following simple application:
I can call the method thusly:
.. And that's all good. But since I don't actually have any POST content here, I would assume that I could omit the Content-Type header. And that's where things look wrong:
The problem here is two-fold.
Firstly, if there is no POST body, then one would assume that omitting the Content-Type header would be appropriate.
Secondly, and more significantly, the 406 status code is inappropriate in this case. A 406 Not Acceptable refers to the server being unable to produce the type requested by the Accept header. This is clearly not the case here. If it is necessary to return an error in this case, the appropriate error would be 415 Unsupported Media Type.
Reproduced as reported above, today on latest fetched version, specifically: github.com/emicklei/go-restful/v3 v3.3.1
The text was updated successfully, but these errors were encountered: