users@jersey.java.net

[Jersey] Re: charset and space

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Mon, 29 Apr 2013 18:51:18 +0200

You can also return Response from your method and set the content type directly in the returned response.

However, note that some containers can still re-parse and rewrite the header values. It would better be dealt on the side of your Python client, otherwise you may find yourself solving similar issues over and over again. It's the problem of that client after all...

Marek

On Apr 26, 2013, at 10:05 AM, George Cao <matrix3456_at_gmail.com> wrote:

> One solution may be using custom ContainerResponseFilter to modify the Content-Type header to what the library required.
>
>
> 2013/4/26 D'Arcy Smith <ds_at_terratap.com>
> I've got:
> @Produces(
> {
> MediaType.APPLICATION_JSON + "; charset=utf-8",
> MediaType.APPLICATION_XML + "; charset=utf-8",
> })
> which results in a header like:
>
> Content-Type: application/xml;charset=utf-8
> However some other code (a Python library) requires it to be like:
>
> Content-Type: application/xml; charset=utf-8
> (note the space between the ; and charset).
>
> From what I can tell the space is optional, but the Python library (out of our control) requires it.
>
> Any ideas on what I need to do to convince JAX-RS to spit out the space?
>
> Thanks,
>
> ..darcy
>