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- 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 <andrea@softinstigate.com>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.undertow.util.AttachmentKey<io.undertow.connector.PooledByteBuffer[]> Fields inherited from class org.restheart.exchange.Exchange
APPLICATION_PDF_TYPE, FORM_URLENCODED, HAL_JSON_MEDIA_TYPE, IN_ERROR_KEY, JSON_MEDIA_TYPE, MAX_BUFFERS, MAX_CONTENT_SIZE, MULTIPART, TEXT_PLAIN_CONTENT_TYPE, wrapped -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProxyResponse(io.undertow.server.HttpServerExchange exchange) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this resource, relinquishing any underlying PooledByteBuffer.io.undertow.connector.PooledByteBuffer[]protected abstract TgetErrorContent(int code, String httpStatusText, String message, Throwable t, boolean includeStackTrace) io.undertow.util.AttachmentKey<io.undertow.connector.PooledByteBuffer[]> booleanabstract Treads 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 TMethods inherited from class org.restheart.exchange.Response
getContentType, getContentType, getHeader, getHeader, getHeaders, getMDCContext, getStatusCode, of, setContentType, setContentTypeAsJson, setHeader, setHeader, setInError, setMDCContext, setStatusCodeMethods inherited from class org.restheart.exchange.Exchange
getExchange, getWrappedExchange, isAccountInRole, isAuthenticated, isAuthenticated, isContentTypeFormOrMultipart, isContentTypeFormOrMultipart, isContentTypeJson, isContentTypeJson, isContentTypeText, isContentTypeXml, isInError, isInError, responseInterceptorsExecuted, setInError, setInError, setResponseInterceptorsExecuted, updateBufferSize
-
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
Description copied from interface:BufferedExchangereads data from the buffer converting it to T- Specified by:
readContentin interfaceBufferedExchange<T>- Returns:
- Throws:
IOException
-
writeContent
Description copied from interface:BufferedExchangewrites data the buffer from T- Specified by:
writeContentin interfaceBufferedExchange<T>- Parameters:
content-- 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
- 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
-
close
public void close()Closes this resource, relinquishing any underlying PooledByteBuffer.- Specified by:
closein interfaceAutoCloseable
-