hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Should DefaultHttpClient add ResponseContentEncoding response handler as default?
Date Thu, 07 Apr 2011 08:22:53 GMT
On Thu, 2011-04-07 at 01:18 +0100, sebb wrote:
> The DefaultHttpClient class sets up a lot of HttpResponseInterceptors,
> but does not currently include ResponseContentEncoding which handles
> Content-Encoding (e.g. gzip)
> 
> Seems like a strange omission.
> 
>
> Its subclass ContentEncodingHttpClient adds ResponseContentEncoding,
> but also adds RequestAcceptEncoding which might not be wanted for all
> requests.
> 
> For example, JMeter creates an HttpClient instance, and may or may not
> add the Accept-Encoding header later. So it has to sub-class
> DefaultHttpClient to add the handler.
> 
> Would there be any drawback to including ResponseContentEncoding in
> DefaultHttpClient by default?
> 

Hi Sebastian
 
This was a conscious decision to avoid conflicts with custom content
coding solutions that may have been developed for HttpClient 4.0.  

We can certainly revisit that decision for 4.2

Please note, though, one can dynamically enable content coding support
by adding two protocol interceptors at run time

---
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.addRequestInterceptor(new RequestAcceptEncoding());
httpclient.addResponseInterceptor(new ResponseContentEncoding());
---

The critical bit is to make sure to not add them more than once

Cheers

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message