You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Oleg Kalnichevski <ol...@apache.org> on 2008/06/28 01:43:56 UTC

Response handler API; was Re: Can we make it easier to release resources?

On Fri, 2008-06-20 at 11:50 -0700, Bob Lee wrote:

...

> 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

Folks,

I added support for response handlers as suggested by Bob. Here's the
example of the new API

http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicResponseHandler.java

I think it turned out pretty neat.

Bob, please review.

Oleg


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


Re: Response handler API; was Re: Can we make it easier to release resources?

Posted by Sam Berlin <sb...@gmail.com>.
This looks really cool!  Makes it much easier to use HttpClient for
everyday usage.

Sam

On Fri, Jun 27, 2008 at 7:43 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Fri, 2008-06-20 at 11:50 -0700, Bob Lee wrote:
>
> ...
>
>> 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
>
> Folks,
>
> I added support for response handlers as suggested by Bob. Here's the
> example of the new API
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicResponseHandler.java
>
> I think it turned out pretty neat.
>
> Bob, please review.
>
> 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