-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
AbstractMessageConverterMethodProcessor results in 406 with "Accept: */*" when @RequestMapping produces condition determined the content type #23287
Comments
This is a serious problem in reporting error the client users! |
This is an empty spring-boot application with one dependency on I not remember exact spring-boot version, but it is between 2.1.3 and 2.1.6 I think. |
Tentatively scheduled for 5.2.3. |
Yes, that is my point. 406 should be returned only when server is unable to select the type requested by a client. But in the mentioned case the server can select it. It just unable to write the response because of server misconfiguration. |
Re-opening, closed in error due to incorrect issue reference from above commit. |
Following #23205 I found a similar issue.
If you declare a controller like this:
And make a request like this (httpie):
Then the result will be:
AbstractMessageConverterMethodProcessor#writeWithMessageConverters
method will throworg.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
.This is very similar case to a case with
ResponseEntity
- the server is responsible for selecting content-typeapplication/xml
(if it is acceptable by a client, and in this case - it is) and no converters found that can write the result using this content-type.The
Accept
header was taken into account but it wasAccept: */*
so it is obviously not "Could not find acceptable representation" case, but more like a "Cound not find http message converter for totally acceptable representation" (application/xml
is acceptable for a client, that requsted it withAccept: */*
).So it is strange to receive a 406 result for a request with
Accept: */*
header. The real problem in this case is a server misconfiguration: the server declares that it producesapplication/xml
, but at the same time it didn't register anyHttpMessageConverter
that can return this content type. How can this be a 4xx then?The text was updated successfully, but these errors were encountered: