By default, the GZIP out stuff on the client uses a "negotiated" method where 
the first request is not-gzipped, but with the Accept-Encoding header since it 
does not know if the server knows how to handle a GZIP post.   If the server 
responds with a GZIP response, subsequent requests from that client will be 
gzipped.     Try making multiple calls with the same client object and see if 
the headers and such change.

You can force the first request to be gzipped by doing:

GZIPOutInterceptor gz = new GZIPOutInterceptor(128)
gz.setForce(true);
client.getOutInterceptors().add(gz);

Hope that helps!

Dan



On Mar 11, 2013, at 12:22 AM, Ted <[email protected]> wrote:

> Hi I just tried gzip compression and it appears to be working in some
> cases but not in others.
> I'm on openjdk 1.7.0.3 and cxf 2.7.3 and tomcat 7.0.27.
> 
> On the server side I've set
>       @GZIP(threshold=128)
> on the web services
> 
> On the client I've set
>       cxfClient.getInInterceptors().add(new GZIPInInterceptor());
>       cxfClient.getOutInterceptors().add(new GZIPOutInterceptor(128));
> 
> I'm logging what's going on with the server with :
>       <bean id="compressGZIPFeature"
> class="org.apache.cxf.transport.common.gzip.GZIPFeature"/>
>       <bean id="loggingFeature" 
> class="org.apache.cxf.feature.LoggingFeature"/>
> 
>       <cxf:bus>
>               <cxf:features>
>                       <ref bean="compressGZIPFeature"/>
>                       <ref bean="loggingFeature"/>
>               </cxf:features>
>       </cxf:bus>
> 
> What I can see is the client is sending
>       Headers: {Accept-Encoding=[gzip;q=1.0, identity; q=0.5, *;q=0]}
> 
> I can see if I have a large response (over 1k) I'm getting
>       Headers: {Content-Encoding=[gzip], Vary=[Accept-Encoding]}
> 
> The 2 problems I'm having is
> 
> 1) the 128 seems to have no effect, I even tried '0' as per the
> documentation for always on, and it does seem to work. Small data is
> just normal / no mention of gzip encoding like the large data
> 
> 2) The requests being sent by the client do not appear to be gziped,
> but honestly I'm not sure how to check or what header to look for.
> Have I missed something in the configuration?
> 
> thanks
> -- 
> Ted.

-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to