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 Gaurav Kumar <ga...@gmail.com> on 2014/01/10 21:49:20 UTC

asynchronously getting response status and headers in async httpclient

I went through the
examples<http://hc.apache.org/httpcomponents-asyncclient-dev/examples.html>
but
couldn't find a simple way to asynchronously read response status and
headers. This<http://hc.apache.org/httpcomponents-asyncclient-dev/httpasyncclient/examples/org/apache/http/examples/nio/client/AsyncClientConfiguration.java>
example
shows how to use responseParserFactory but I think it is too complex for my
need. I just need a simple callback something like onHeadersReceive(),
onStatusReceive() and onBodyReceive().


On a related note,
this<http://hc.apache.org/httpcomponents-asyncclient-dev/httpasyncclient/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeStreaming.java>example
is great for textual entities but how do I handle non-textual
entities. In other words, is there a simple way to get access to raw bytes
received asynchronously?

Thanks,
Gaurav

Re: asynchronously getting response status and headers in async httpclient

Posted by Gaurav Kumar <ga...@gmail.com>.
I just found found out the answer to my related question -how to access raw
bytes asynchronously. One can use
org.apache.http.nio.client.methods.AsyncByteConsumer
​​



On Fri, Jan 10, 2014 at 12:49 PM, Gaurav Kumar <ga...@gmail.com>wrote:

> I went through the examples<http://hc.apache.org/httpcomponents-asyncclient-dev/examples.html> but
> couldn't find a simple way to asynchronously read response status and
> headers. This<http://hc.apache.org/httpcomponents-asyncclient-dev/httpasyncclient/examples/org/apache/http/examples/nio/client/AsyncClientConfiguration.java> example
> shows how to use responseParserFactory but I think it is too complex for
> my need. I just need a simple callback something like onHeadersReceive(),
> onStatusReceive() and onBodyReceive().
>
>
> On a related note, this<http://hc.apache.org/httpcomponents-asyncclient-dev/httpasyncclient/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeStreaming.java>example is great for textual entities but how do I handle non-textual
> entities. In other words, is there a simple way to get access to raw bytes
> received asynchronously?
>
> Thanks,
> Gaurav
>
>