I want to have a send a request body generating the body a piece at a time, but without knowing the entire length ahead of time. In other words, I need to send a chunked request.
I can't find how to do this.
The main distinction between two types of connections is inability to use the usual, but inherently blocking
java.io.InputStream
andjava.io.OutputStream
classes to represent streams of inbound and outbound content. HttpCore NIO providesContentEncoder
andContentDecoder
interfaces to handle the process of asynchronous content transfer....
Non-blocking HTTP connections will fire output events until the content entity is marked as fully transferred.
ContentEncoder encoder = <...> // Prepare output data ByteBuffer src = ByteBuffer.allocate(2048); // Write data out encoder.write(src); // Mark content entity as fully transferred when done encoder.complete();
I looked at org.apache.http.nio.conn.ClientAsyncConnection
, but I can't see where the output events are being fired.
I can find examples for sending files, but none for the content generation that I want to do.
How do I send a streaming, chunked request with the AsyncHttpClient
?