On Wed, 2018-04-04 at 21:01 +0000, Mark A. Claassen wrote: > I am finally getting chance to start with HttpClient 5 and HTTP/2. I > am currently using 4.4. > > I am first trying to do a relatively simple port, meaning that I am > trying to keep as much of the existing code as I can. I already have > an internal API that reads the entity objects from the > CloseableHttpResponse, so I am trying to get something that looks as > close to that as possible. > > Looking at the examples, I think I need to use the Async client for > HTTP/2. I created a CloseableHttpAsyncClient which I can call > execute on and get a SimpleHttpResponse. However, this object > doesn't give me anything I can easily convert to an input stream, > just things like getText() and getBytes(). Getting an input stream > is pretty fundamental to my internal API, so not being able to get > that is going to make my job quite a bit more difficult. > > If I use a different call to execute() and get a ResponseConsumer, it > looks like I can do more stream like things, but seems like a lot for > the little I want. > > I certainly still need to poor over the examples ore and try to > figure all this out. However, a nudge in the right direction would > be extremely appreciated. > > Thanks! >
Hi Mark Classic client APIs in HttpClient 5.0 will give you very similar, mostly compatible APIs with HttpClient 4.x but no HTTP/2. If you want to utilize HTTP/2 you should be using async APIs provided by HttpClient 5.0. HttpAsyncClient is perfectly capable of streaming both request and response data (in full-duplex if desired) but you would lose convenience of InputStream/OutputStream APIs and would need to structure your application logic in terms of callback methods reacting to various events during HTTP message exchanges: https://github.com/apache/httpcomponents-client/blob/master/httpclient5 /src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchan geStreaming.java https://github.com/apache/httpcomponents-client/blob/master/httpclient5 /src/examples/org/apache/hc/client5/http/examples/AsyncClientFullDuplex Exchange.java Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org