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

[jsr339-experts] Re: ResponseBuilder and setting headers

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Wed, 14 Dec 2011 16:10:20 +0000

On 14/12/11 13:42, Marek Potociar wrote:
> 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()));

Yes indeed, thanks; this one can help with Response to Response copy, up
to the experts

Cheers, Sergey

>
> 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