hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Can we make it easier to release resources?
Date Fri, 20 Jun 2008 23:16:06 GMT
Bob Lee wrote:
> Right now, we have to do something like this:
> 
> HttpResponse r = client.execute(...)
> try {
>   ...
> } finally {
>   HttpEntity e = r.getEntity();
>   if (e != null) {
>     // Soon to be renamed finish()
>     e.consumeContent();
>   }
> }
> 
> It might be nice if we could do something like this:
> 
> HttpResponse r = client.execute(...)
> try {
>   ...
> } finally {
>    response.finish();
> }
> 
> Or even something like this:
> 
> public interface ResponseHandler<T> {
>   T handle(HttpResponse response) throws IOException;
> }
> 
> String result = client.execute(myHandler);
> 
> Then you could have a few reusable response handlers, like a JSON handler,
> and XML handler, etc.
> 
> Bob
> 

Hi Bob

I _really_, _really_ like this idea. However, what shall HttpClient do 
if it gets status code other than 200? Throw an exception? Ignore the 
status code?

Oleg


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


Mime
View raw message