Package org.restheart.exchange
Class ProxyResponse<T>
- java.lang.Object
-
- org.restheart.exchange.Exchange<T>
-
- org.restheart.exchange.Response<T>
-
- org.restheart.exchange.ProxyResponse<T>
-
- Type Parameters:
T-
- All Implemented Interfaces:
BufferedExchange<T>
- Direct Known Subclasses:
ByteArrayProxyResponse,JsonProxyResponse
public abstract class ProxyResponse<T> extends Response<T> implements BufferedExchange<T>
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
-
-
Field Summary
Fields Modifier and Type Field Description static io.undertow.util.AttachmentKey<io.undertow.connector.PooledByteBuffer[]>BUFFERED_RESPONSE_DATA_KEY-
Fields inherited from class org.restheart.exchange.Exchange
APP_FORM_URLENCODED_TYPE, APPLICATION_PDF_TYPE, HAL_JSON_MEDIA_TYPE, IN_ERROR_KEY, JSON_MEDIA_TYPE, LOGGER, MAX_BUFFERS, MAX_CONTENT_SIZE, MULTIPART_FORM_DATA_TYPE, wrapped
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedProxyResponse(io.undertow.server.HttpServerExchange exchange)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description io.undertow.connector.PooledByteBuffer[]getBuffer()protected abstract TgetErrorContent(int code, String httpStatusText, String message, Throwable t, boolean includeStackTrace)io.undertow.util.AttachmentKey<io.undertow.connector.PooledByteBuffer[]>getRawContentKey()booleanisContentAvailable()abstract TreadContent()reads data from the buffer converting it to TvoidsetBuffer(io.undertow.connector.PooledByteBuffer[] raw)protected voidsetContentLength(int length)voidsetInError(int code, String message, Throwable t)abstract voidwriteContent(T content)writes data the buffer from T-
Methods inherited from class org.restheart.exchange.Response
getContentType, getContentType, getMDCContext, getStatusCode, of, setContentType, setContentTypeAsJson, setInError, setMDCContext, setStatusCode, type
-
Methods inherited from class org.restheart.exchange.Exchange
getExchange, getWrappedExchange, isAccountInRole, isAuthenticated, isAuthenticated, isContentTypeJson, isContentTypeText, isContentTypeXml, isInError, isInError, responseInterceptorsExecuted, setInError, setInError, setResponseInterceptorsExecuted, updateBufferSize
-
-
-
-
Method Detail
-
readContent
public abstract T readContent() throws IOException
Description copied from interface:BufferedExchangereads data from the buffer converting it to T- Specified by:
readContentin interfaceBufferedExchange<T>- Returns:
- Throws:
IOException
-
writeContent
public abstract void writeContent(T content) throws IOException
Description copied from interface:BufferedExchangewrites data the buffer from T- Specified by:
writeContentin interfaceBufferedExchange<T>- Throws:
IOException
-
getRawContentKey
public io.undertow.util.AttachmentKey<io.undertow.connector.PooledByteBuffer[]> getRawContentKey()
-
getBuffer
public io.undertow.connector.PooledByteBuffer[] getBuffer()
- Specified by:
getBufferin interfaceBufferedExchange<T>
-
setBuffer
public void setBuffer(io.undertow.connector.PooledByteBuffer[] raw)
- Specified by:
setBufferin interfaceBufferedExchange<T>
-
isContentAvailable
public boolean isContentAvailable()
- Specified by:
isContentAvailablein interfaceBufferedExchange<T>
-
setContentLength
protected void setContentLength(int length)
-
setInError
public void setInError(int code, String message, Throwable t)- Specified by:
setInErrorin classResponse<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
-
-