jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: ResponseBuilder and setting headers

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Wed, 14 Dec 2011 14:42:13 +0100

Irrespective of the usefulness of the proposed method, isn't your use case solved by the fact that filter context can
return current response as a ResponseBuilder with all the original headers and stuff pre-filled? IOW:

ctx.getResponseBuilder().entity(updateEntity(ctx.getResponse()));

Marek

On 12/14/2011 11:30 AM, Sergey Beryozkin wrote:
> Hi
>
> I'd like to propose adding
>
> ResponseBuilder.headers(ResponseHeaders allHeaders)
> and/or
> ResponseBuilder.headers(MultivaluedMap<String, String> allHeaders)
>
> method(s).
>
> One thing I found while advising users how to override a Response in custom out filters is that one need to enumerate
> over all the headers of the current Response in order to copy them over to a new one, the following would simplify it a
> lot IMHO:
>
> return Response.status(oldResponse.getStatus())
> .headers(oldResponse.headers())
> .entity(updateEntity(oldResponse.getEntity()))
> .build();
>
> Sergey