It seems like Jersey 2.0 (using servlet 3.1) is not able to decode a parameter when the charset
property is specified in the Content-Type
header.>
I think it's a bug.
There's a pull request open to support this use case: https://github.com/jersey/jersey/pull/24/files
In the meantime I'd suggest to use a filter to remove the offending encoding.
EDIT as per OP comments
I'm thinking on something along these lines:
@Provider
@PreMatching
public class ContentTypeFilter implements ContainerRequestFilter{
@Override
public void filter(ContainerRequestContext requestContext)
throws IOException {
MultivaluedMap headers=requestContext.getHeaders();
List contentTypes=headers.remove(HttpHeaders.CONTENT_TYPE);
if (contentTypes!=null && !contentTypes.isEmpty()){
String contentType= contentTypes.get(0);
String sanitizedContentType=contentType.replaceFirst(";.*", "");
headers.add(HttpHeaders.CONTENT_TYPE, sanitizedContentType);
}
}
}