Class ProxyResponse<T>

Type Parameters:
T - generic type
All Implemented Interfaces:
AutoCloseable, BufferedExchange<T>
Direct Known Subclasses:
ByteArrayProxyResponse, JsonProxyResponse

public abstract class ProxyResponse<T> extends Response<T> implements BufferedExchange<T>, AutoCloseable
Base class for Response implementation that can be used in proxied requests. It stores the response content in the BUFFERED_RESPONSE_DATA_KEY attachment of the HttpServerExchange.
Author:
Andrea Di Cesare <[email protected]>
  • Field Details

    • BUFFERED_RESPONSE_DATA_KEY

      public static final io.undertow.util.AttachmentKey<io.undertow.connector.PooledByteBuffer[]> BUFFERED_RESPONSE_DATA_KEY
  • Constructor Details

    • ProxyResponse

      protected ProxyResponse(io.undertow.server.HttpServerExchange exchange)
  • Method Details

    • readContent

      public abstract T readContent() throws IOException
      Description copied from interface: BufferedExchange
      reads data from the buffer converting it to T
      Specified by:
      readContent in interface BufferedExchange<T>
      Returns:
      Throws:
      IOException
    • writeContent

      public abstract void writeContent(T content) throws IOException
      Description copied from interface: BufferedExchange
      writes data the buffer from T
      Specified by:
      writeContent in interface BufferedExchange<T>
      Throws:
      IOException
    • getRawContentKey

      public io.undertow.util.AttachmentKey<io.undertow.connector.PooledByteBuffer[]> getRawContentKey()
    • getBuffer

      public io.undertow.connector.PooledByteBuffer[] getBuffer()
      Specified by:
      getBuffer in interface BufferedExchange<T>
    • setBuffer

      public void setBuffer(io.undertow.connector.PooledByteBuffer[] raw)
      Specified by:
      setBuffer in interface BufferedExchange<T>
    • isContentAvailable

      public boolean isContentAvailable()
      Specified by:
      isContentAvailable in interface BufferedExchange<T>
    • setContentLength

      protected void setContentLength(int length)
    • setInError

      public void setInError(int code, String message, Throwable t)
      Specified by:
      setInError in class Response<T>
      Parameters:
      code -
      message -
      t -
    • getErrorContent

      protected abstract T getErrorContent(int code, String httpStatusText, String message, Throwable t, boolean includeStackTrace) throws IOException
      Parameters:
      code -
      httpStatusText -
      message -
      t -
      includeStackTrace -
      Returns:
      the content descibing the error
      Throws:
      IOException
    • close

      public void close()
      Closes this resource, relinquishing any underlying PooledByteBuffer.
      Specified by:
      close in interface AutoCloseable