Interface HttpResponse.BodyProcessor<T>

Type Parameters:
T - the type of the response body
Enclosing interface:
HttpResponse

public static interface HttpResponse.BodyProcessor<T>
A processor for response bodies, which determines the type of the response body returned from HttpResponse.
  • Method Details

    • onResponseBodyStart

      void onResponseBodyStart(long contentLength, HttpHeaders responseHeaders, LongConsumer flowController) throws IOException
      Called immediately before the response body is read.
      Parameters:
      contentLength - -1 signifies unknown content length. Otherwise, a positive integer, or zero.
      responseHeaders - the response headers
      flowController - a LongConsumer used to update the flow control window
      Throws:
      IOException - if an exception occurs starting the response body receive
    • onResponseBodyChunk

      void onResponseBodyChunk(ByteBuffer byteBuffer) throws IOException
      Called for each buffer of data received for this response.
      Parameters:
      byteBuffer - a ByteBuffer whose position is at the first byte that can be read, and whose limit is after the last byte that can be read
      Throws:
      IOException - in case of I/O error
    • onResponseComplete

      T onResponseComplete() throws IOException
      Called after the last time onResponseBodyChunk(ByteBuffer) has been called and returned indicating that the entire content has been read. This method must return an object that represents or contains the response body just received.
      Returns:
      the T response body
      Throws:
      IOException - in case of I/O error
    • onResponseError

      void onResponseError(Throwable t)
      Called if an error occurs while reading the response body. This terminates the operation and no further calls will occur after this.
      Parameters:
      t - the Throwable