Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Improve support for fixed content type in ContentNegotiationManager [SPR-15367] #19931
ContentNegotiationConfigurer currently supports setting a default content type for all end points, or a content negotiation strategy. While useful, this can run into problems for applications with a variety of supported content types.
For example, if an application has set the default content type to "text/html", and has an end point which only supports "application/json", any calls which do not specify an accept header, or which specify "*/*" as the accept header, will receive a 406 response.
This is consistent with the documented behavior of setting the default content type, but applications such as these often would like to specify the preferred content type, as opposed to a forced default.
Such a configuration would ideally allow the above example to specify that endpoints that support "text/html" prefer to return it when no specific content type is requested, but still allow end points which do not support "text/html" to chose from among the media types they support (in the same manner as when no default content type is specified)
Reference URL: #1362
Ryan O'Meara commented
An example of what I'd like this to look like (attempting to be consistent with existing patterns):
I have successfully, in a local application, created a content negotiation strategy which replicates the desired behavior - I'm more than willing to contribute a pull request if you agree that this is a desirable feature to add (and that this is the correct way to add it)