Interface HttpRequest.BodyProcessor

Enclosing interface:
HttpRequest

public static interface HttpRequest.BodyProcessor
A request processor which obtains the request body from some source.
  • Method Details

    • onRequestStart

      long onRequestStart(HttpRequest httpRequest, LongConsumer flowController) throws IOException
      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 request
      flowController - the HttpFlowController
      Returns:
      the content length
      Throws:
      IOException - if an I/O error occurs
    • onRequestBodyChunk

      boolean onRequestBodyChunk(ByteBuffer buffer) throws IOException
      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

      default void onRequestError(Throwable t)
      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