You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Laurent Perez <ha...@gmail.com> on 2009/05/16 00:22:27 UTC

Preferred use of HttpResponseInterceptor ?

Hi

I'm familiar with httpclient v3, but not with v4. The new interceptors
are interesting, but I'm wondering if I should use them, given my
following use case.
I need to be able to check various response headers, for example
status code, and treat them as exceptions.

Previously, I wrote my own response checking stuff, but I'm wondering
if I could move some of this into a HttpResponseInterceptor, given its
process signature can throw HttpException.

Is it considered a good practice to move "response checking" scenarios
directly into the newly available interceptors, or should I just
abort() the method itself, as I used to do previously ? As far as I
understand it, it looks like response interceptors are good candidates
for transparent response wrapping, but I'm wondering if they were also
intended as "triggers" for response handling cases.

Thanks for your insight :)

laurent


-- 
<a href="http://in-pocket.blogspot.com">http://in-pocket.blogspot.com
- Mobile world, technology and more</a>

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


Re: Preferred use of HttpResponseInterceptor ?

Posted by Oleg Kalnichevski <ol...@apache.org>.
Laurent Perez wrote:
> Hi
> 
> I'm familiar with httpclient v3, but not with v4. The new interceptors
> are interesting, but I'm wondering if I should use them, given my
> following use case.
> I need to be able to check various response headers, for example
> status code, and treat them as exceptions.
> 
> Previously, I wrote my own response checking stuff, but I'm wondering
> if I could move some of this into a HttpResponseInterceptor, given its
> process signature can throw HttpException.
> 
> Is it considered a good practice to move "response checking" scenarios
> directly into the newly available interceptors, or should I just
> abort() the method itself, as I used to do previously ? As far as I
> understand it, it looks like response interceptors are good candidates
> for transparent response wrapping, but I'm wondering if they were also
> intended as "triggers" for response handling cases.
> 
> Thanks for your insight :)
> 
> laurent
> 
> 

Laurent,

Usually one may want to use interceptors in order to implement some 
common processing that applies to all incoming / outgoing message 
without cluttering the application specific logic with handling of 
cross-cutting aspects.

The idea of moving message validation code to a protocol interceptor / a 
set of interceptors seems reasonable to me.

Hope this helps

Oleg



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