public static interface HttpRequest.BodyProcessor
String, byte[], File, InputStream
.
Other implementations can be provided.
The methods of this interface may be called from multiple threads, but only one method is invoked at a time, and behaves as if called from one thread.
See HttpRequest
for implementations that take request bodies from
byte arrays, Strings, Paths
etc.
Modifier and Type | Method and Description |
---|---|
default void |
onComplete()
Called when the request body has been completely sent.
|
java.nio.ByteBuffer |
onRequestBodyChunk(java.nio.ByteBuffer buffer)
Called multiple times to send request body data.
|
default void |
onRequestError(java.lang.Throwable t)
Called if sending a request body fails.
|
long |
onRequestStart(HttpRequest hr)
Called before a request is sent.
|
long onRequestStart(HttpRequest hr) throws java.io.IOException
hr
- the request being sentjava.io.IOException
- if the request cannot be sent.default void onRequestError(java.lang.Throwable t)
t
- the Throwable that caused the failurejava.nio.ByteBuffer onRequestBodyChunk(java.nio.ByteBuffer buffer) throws java.io.IOException
null
.
If an exact content length was provided
in onRequestStart()
, then that number of bytes must be provided.
Otherwise, the request will fail.buffer
- a ByteBuffer to write data intojava.io.IOException
- in case of I/O errordefault void onComplete()