users@jersey.java.net

Re: [Jersey] Adding Header to Response

From: Andy <a.begau_at_googlemail.com>
Date: Thu, 22 Oct 2009 15:17:52 +0200

On 22.10.2009 13:48, Paul Sandoz wrote:
> On Oct 22, 2009, at 1:38 PM, Andy wrote:
>>> What client are you using? is it performing automatic redirection on
>>> requests?
>> The mentioned headers are received at the redirected URI
>> (http://localhost:9998/mockup/dummy). This is where the header
>> "X-FOO" is expected, but it is missing.
>
> The X-FOO response header will only be sent in the 307 (Temporary
> Redirect) response (as is the case for the Location header with the
> URI to redirect to).
>
> What is happening is the client API is performing automatic
> redirection to the redirected URI.
>
> Try setting redirection to false:
>
> https://jersey.dev.java.net/nonav/apidocs/1.1.2-ea/jersey/com/sun/jersey/api/client/Client.html#setFollowRedirects%28java.lang.Boolean%29
>
> and look at the response headers.
>
> You need to modify the response returned from the
> URI ttp://localhost:9998/mockup/dummy to return the X-FOO header.
Ok thanks, I think redirection is the wrong approach for my case.
Is there a way to simply forward a complete response (JSON or any other
format) from another server to the client without deserializing it into
a (JAXB-)Java class? Only the client needs to deserialize the message.

Andy