hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Should DefaultHttpClient add ResponseContentEncoding response handler as default?
Date Thu, 07 Apr 2011 11:50:20 GMT
On 7 April 2011 09:22, Oleg Kalnichevski <olegk@apache.org> wrote:
> 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.

I see.

> We can certainly revisit that decision for 4.2

Probably should be optional to avoid unnecessary code changes.

> 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());

Yes, I discovered that later; it would be useful to add it to the
Javadoc (I'll take care of that).

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

Which means we should be careful to document the interceptors that are
being added ;-)

The class Javadoc mentions only 10 interceptors but
createHttpProcessor() adds 12.

I propose to take care of that by adding the Javadoc to the method,
and referencing that from the class Javadoc.

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

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


Mime
View raw message