You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose an HTTP client submits a request to the server with header "Accept: /" or even no accept header at all. Clearly, a json response is acceptable here. In both cases jersey will set the MediaType of the request to "/" (in the absense of any @produces annotation on the resource method).
The code eventually comes to jackson-jaxrs-json-provider-2.9.6-sources.jar:com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider:hasMatchingMediaType which returns false for MediaType.WILDCARD_TYPE.
I think that in this case it should return true. And by extension it should return true for application/* media types.
In other words, mediaType = MediaType.WILDCARD_TYPE should be handled in the same way as mediaType = null.
Should be easy to add in 2.11 (too risky for inclusion in patches, like 2.10.3). But would be great would be a test case to show expected usage -- do clients actually send wildcard matches? Or, rather, does Jersey (et al) map empty/missing Accept header as wild card?
Also: should the same change be made for all format providers, not just json? I assume so?
My main concern here is actually that behavioral change may break some users, so there is also question of downsides, potential breakages.
Suppose an HTTP client submits a request to the server with header "Accept: /" or even no accept header at all. Clearly, a json response is acceptable here. In both cases jersey will set the MediaType of the request to "/" (in the absense of any @produces annotation on the resource method).
The code eventually comes to jackson-jaxrs-json-provider-2.9.6-sources.jar:com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider:hasMatchingMediaType which returns false for MediaType.WILDCARD_TYPE.
I think that in this case it should return true. And by extension it should return true for application/* media types.
In other words, mediaType = MediaType.WILDCARD_TYPE should be handled in the same way as mediaType = null.
jackson-jaxrs-providers/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JacksonJsonProvider.java
Line 168 in 9958c03
The text was updated successfully, but these errors were encountered: