Reputation: 395
Does anybody know a way to enable response character set selection by client for RESTeasy? I'm working with 1.2.1GA. My responses return UTF-8 although I'm not sure why and where that is defined because my test system's default encoding in java is CP1252-something and the annotations looked like that:
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
I tried to vary these MediaTypes with no success.
// Add another media type
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, "application/json;charset=iso-8859-1" } )
// Try to always return latin-1 JSON. TESTING ONLY!!!
@Produces( { MediaType.APPLICATION_JSON + ";charset=iso-8859-1", MediaType.APPLICATION_XML } )
I request with REST Client for Firefox setting the charset in the accept and accept-encoding headers and still I always get UTF-8 JSON. But the client that needs the data is going to be included in a latin-1 web page, which is quite... you know. I can't influence that. I'd like to avoid re-encoding that all manually in JavaScript. In addition the serverside solution seems much more solid to me.
I also tried some other stuff which I was never really expecting to work, like changing response character encoding with a servlet filter and so on. (Necessity is the mother of invention. ^^)
Google/the web don't have much to offer on this topic so after hours of trying I now come here and hope somebody might tell me how this is intended to work or if it's even possible.
So long, regards
S.Frank
Upvotes: 2
Views: 3862
Reputation: 3069
Dynamically reencoding the returned response is not supported yet: https://issues.jboss.org/browse/RESTEASY-465
It seems that there is limited support when using JAX-B return types though: https://issues.jboss.org/browse/RESTEASY-269
Upvotes: 3