users@jax-rs-spec.java.net

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

From: Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com>
Date: Thu, 8 Nov 2012 09:22:21 -0500

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

> I don't know if the spec explicity supports this, but our impmlementation does.
>
> On 11/8/2012 2:30 AM, Jan Algermissen wrote:
>>
>>
>> @Provider
>> class TestInterceptor implements WriterInterceptor {
>>
>> @Context
>> HttpHeaders headers;
>>
>> @Override
>> public void aroundWriteTo(WriterInterceptorContext wCtx)
>> throws IOException, WebApplicationException {
>>
>> String h = headers.getHeaderString("Accept-Encoding");
>> if(if h !=null && h.contains("gzip") ) {
>> // hook gzipper into the ostream
>> }
>> }
>> }

 Yes, injecting HttpHeaders would be the portable way to do it. Section 8.1 talks about the use of thread local proxies as a common solution to the scoping issue.

-- Santiago