Class BuiltResponse

All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
BuiltResponseEntityNotBacked, ClientResponse, ServerResponse

public class BuiltResponse extends AbstractBuiltResponse
A response object not attached to a client or server invocation.
Version:
$Revision: 1 $
Author:
Bill Burke
  • Constructor Details

  • Method Details

    • readEntity

      public <T> T readEntity(Class<T> type, Type genericType, Annotation[] anns)
      Specified by:
      readEntity in class AbstractBuiltResponse
    • readFrom

      protected <T> Object readFrom(Class<T> type, Type genericType, MediaType media, Annotation[] annotations)
    • getEntityStream

      protected InputStream getEntityStream()
      Specified by:
      getEntityStream in class AbstractBuiltResponse
    • setInputStream

      protected void setInputStream(InputStream is)
      Specified by:
      setInputStream in class AbstractBuiltResponse
    • getInputStream

      protected InputStream getInputStream()
      Specified by:
      getInputStream in class AbstractBuiltResponse
    • releaseConnection

      public void releaseConnection() throws IOException
      Description copied from class: AbstractBuiltResponse
      Release underlying connection but do not close.
      Specified by:
      releaseConnection in class AbstractBuiltResponse
      Throws:
      IOException - if I/O error occurred
    • releaseConnection

      public void releaseConnection(boolean consumeInputStream) throws IOException
      Description copied from class: AbstractBuiltResponse
      Release underlying connection but do not close.
      Specified by:
      releaseConnection in class AbstractBuiltResponse
      Parameters:
      consumeInputStream - boolean to indicate either the underlying input stream must be fully read before releasing the connection or not.

      For most HTTP connection implementations, consuming the underlying input stream before releasing the connection will help to ensure connection reusability with respect of Keep-Alive policy.

      Throws:
      IOException - if I/O error occured
    • bufferEntity

      public boolean bufferEntity()
      Description copied from class: Response
      Buffer the message entity data.

      In case the message entity is backed by an unconsumed entity input stream, all the bytes of the original entity input stream are read and stored in a local buffer. The original entity input stream is consumed and automatically closed as part of the operation and the method returns true.

      In case the response entity instance is not backed by an unconsumed input stream an invocation of bufferEntity method is ignored and the method returns false.

      This operation is idempotent, i.e. it can be invoked multiple times with the same effect which also means that calling the bufferEntity() method on an already buffered (and thus closed) message instance is legal and has no further effect. Also, the result returned by the bufferEntity() method is consistent across all invocations of the method on the same Response instance.

      Buffering the message entity data allows for multiple invocations of readEntity(...) methods on the response instance. Note however, that once the response instance itself is closed, the implementations are expected to release the buffered message entity data too. Therefore any subsequent attempts to read a message entity stream on such closed response will result in an IllegalStateException being thrown.

      Specified by:
      bufferEntity in class Response
      Returns:
      true if the message entity input stream was available and was buffered successfully, returns false if the entity stream was not available.