Interface HttpRequest.BodyProcessor
- Enclosing interface:
- HttpRequest
public static interface HttpRequest.BodyProcessor
A request processor which obtains the request body from some source.
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]getBytes()default voidCalled when the request body has been completely sent.booleanonRequestBodyChunk(ByteBuffer buffer) Called to obtain a buffer of data to send.default voidCalled if sending a request body fails.longonRequestStart(HttpRequest httpRequest, LongConsumer flowController) Called before a request is sent.
-
Method Details
-
onRequestStart
Called before a request is sent. Is expected to return the content length of the request body. Zero means no content. Less than zero means an unknown positive content-length, and the body will be streamed.- Parameters:
httpRequest- the requestflowController- the HttpFlowController- Returns:
- the content length
- Throws:
IOException- if an I/O error occurs
-
onRequestBodyChunk
Called to obtain a buffer of data to send. The data must be placed in the provided buffer. The implementation should not block. The boolean return code notifies the protocol implementation if the supplied buffer is the final one (or not).- Parameters:
buffer- a ByteBuffer to write data into- Returns:
- whether or not this is the last buffer
- Throws:
IOException- if an I/O error occurs
-
onComplete
default void onComplete()Called when the request body has been completely sent. -
onRequestError
Called if sending a request body fails.- Parameters:
t- the Throwable that caused the failure
-
getBytes
byte[] getBytes()- Returns:
- the bytes of the body.
- Since:
- 2.2.0
-