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
I'm using accept headers for rest api versioning. A @PreMatching request filter is used to set a default rest api version in case the client does not specify the version:
@Provider
@PreMatching
public class APIVersionRequestFilterr implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext containerRequestContext) throws IOException {
List<MediaType> mediaTypes = containerRequestContext.getAcceptableMediaTypes();
containerRequestContext.getHeaders().get("accept").add("application/vnd.x.qi-v3.0+json");
}
}
When I use getAcceptableMediaTypes() to check if the client requested a specific version the following accept header modification has no effect for the resource matching.
When i do not call getAcceptableMediaTypes or use jersey < 2.38 the accept header modification effects the resource matching:
@Path("/")
public class VersionV3{
@Post
@Produces({"application/vnd.x.qi-v3.0+json" })
@Path("/service")
public Response do(){
return Response.ok().build();
}
}
The text was updated successfully, but these errors were encountered:
I tested 2.38, 2.39 and 2.39.1. In all these versions the resource matching changed. Maybe the new acceptTypeCache in InboundMessageContext is the reason the manipulated headers will be ignored and the accepted types in cache will be used for resource matching?
Thanks for your help
Yes, that is a bug. As a workaround, please use containerRequestContext.getHeaders().putSingle("accept","application/vnd.x.qi-v3.0+json");. Well, if you do not mind replacing the existing accept headers, though...
I'm using accept headers for rest api versioning. A @PreMatching request filter is used to set a default rest api version in case the client does not specify the version:
When I use getAcceptableMediaTypes() to check if the client requested a specific version the following accept header modification has no effect for the resource matching.
When i do not call getAcceptableMediaTypes or use jersey < 2.38 the accept header modification effects the resource matching:
The text was updated successfully, but these errors were encountered: