-
Couldn't load subscription status.
- Fork 38.8k
Description
Jarrod Cuzens opened SPR-10761 and commented
We had an issue where we had a RequestMapping that produces="application/json". Our client was not sending an "Accept" header and as a result did not see the json response (received a 404) since the only thing that this method is supposed to produce is JSON.
According to the w3c spec if an "Accept" header is not supplied the default should be "*/*" and if this had been provided then the client would have received the "application/json" response as intended.
The ContentNegotiatingViewResolver does support a defaultMediaType but providing "*/*" does nothing because by the time that the code reaches this default it has already passed the earlier part of the code that looks at the "producibles" to know that it should reply with "application/json".
I would propose refactoring the ContentNegotiatingViewResolver such that when the accept header is not provided and a defaultMediaType is specified that the accept header should be considered to be "*/*" so that it can match the produces attribute.
Affects: 3.1.3
Issue Links:
- ContentNegotiatingViewResolver does not select any views if no content types are requested [SPR-10683] #15311 ContentNegotiatingViewResolver does not select any views if no content types are requested