users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Accessing request in WriterInterceptor.aroundWriteTo() ?

From: Jan Algermissen <jan.algermissen_at_nordsc.com>
Date: Thu, 8 Nov 2012 00:45:33 +0100

On Nov 8, 2012, at 12:39 AM, Bill Burke <bburke_at_redhat.com> wrote:

> Or an injection of ContainerRequestContext?
>
> @Context
> ContainerRequestContext rctx;

Yes, that would be even better - but wouldn't that have to be an instance local to aroundWriteTo?

>> @Override
>> public void aroundWriteTo(WriterInterceptorContext wCtx) ... {
>>
> @Context
> ContainerRequestContext rctx;

>> if( wCtx.getRequest().getHeader('Accept-Encoding') ... 'gzip') {
>> ... hook in gzip output stream
>> }
>>
>> }



Excuse my Java-limits, but isn't that impossible?

Jan



>
>
> On 11/7/2012 5:29 PM, Jan Algermissen wrote:
>>
>> I am wondering: is there a way to access the current request in a WriterIterceptor on the container side?
>>
>> What I want to do is to gzip-encode the output stream but only if the client said 'Accept-Encoding: gzip'.
>>
>> Thus I'd like to be able to do sth like
>>
>> @Override
>> public void aroundWriteTo(WriterInterceptorContext wCtx) ... {
>>
>> if( wCtx.getRequest().getHeader('Accept-Encoding') ... 'gzip') {
>> ... hook in gzip output stream
>> }
>>
>> }
>>
>>
>> What do you think - or what am I missing?
>>
>> Jan
>>
>>
>>
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com