Class HttpResponseBodyPart

java.lang.Object
com.ning.http.client.HttpResponseBodyPart
Direct Known Subclasses:
GrizzlyResponseBodyPart

public abstract class HttpResponseBodyPart extends Object
A callback class used when an HTTP response body is received.
  • Constructor Details

    • HttpResponseBodyPart

      public HttpResponseBodyPart(boolean last)
  • Method Details

    • markUnderlyingConnectionAsToBeClosed

      public void markUnderlyingConnectionAsToBeClosed()
      Close the underlying connection once the processing has completed. Invoking that method means the underlying TCP connection will be closed as soon as the processing of the response is completed. That means the underlying connection will never get pooled.
    • isUnderlyingConnectionToBeClosed

      public boolean isUnderlyingConnectionToBeClosed()
      Return true of the underlying connection will be closed once the response has been fully processed.
      Returns:
      true of the underlying connection will be closed once the response has been fully processed.
    • isLast

      public boolean isLast()
      Return true if this is the last part.
      Returns:
      true if this is the last part.
    • length

      public abstract int length()
      Return length of this part in bytes.
    • getBodyPartBytes

      public abstract byte[] getBodyPartBytes()
      Return the response body's part bytes received.
      Returns:
      the response body's part bytes received.
    • writeTo

      public abstract int writeTo(OutputStream outputStream) throws IOException
      Write the available bytes to the OutputStream
      Parameters:
      outputStream -
      Returns:
      The number of bytes written
      Throws:
      IOException
    • getBodyByteBuffer

      public abstract ByteBuffer getBodyByteBuffer()
      Return a ByteBuffer that wraps the actual bytes read from the response's chunk. The ByteBuffer capacity is equal to the number of bytes available.
      Returns:
      ByteBuffer
    • getPauseHandler

      public PauseHandler getPauseHandler()
      Retrieves a PauseHandler to pause/resume event processing. Useful when an AsyncHandler's resources are saturated, and it can't handle the body part temporarily. If the handler uses the PauseHandler.requestPause() method, it's also responsible for calling PauseHandler.resume() when it could handle the part correctly.
      Returns:
      a PauseHandler to pause the events processing in the current http transaction.