A Handler that can apply a mechanism to buffer the entire response content until the output is closed. This allows the commit to be delayed until the response is complete and thus headers and response status can be changed while writing the body.
Note that the decision to buffer is influenced by the headers and status at the first write, and thus subsequent changes to those headers will not influence the decision to buffer or not.
Note also that the size of the buffer can be controlled by setting the
BUFFER_SIZE_ATTRIBUTE_NAME request attribute to an integer;
in the absence of such header, the HttpConfiguration#getOutputBufferSize()
config setting is used, while the maximum aggregation size can be controlled
by setting the MAX_AGGREGATION_SIZE_ATTRIBUTE_NAME request attribute to an integer,
in the absence of such header, the HttpConfiguration#getOutputAggregationSize()
config setting is used.
| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private final IncludeExclude | |
| public static final String | BUFFER_SIZE_ATTRIBUTE_NAME
The name of the request attribute used to control the buffer size of a particular request. |
| private static final Logger | |
| public static final String | MAX_AGGREGATION_SIZE_ATTRIBUTE_NAME
The name of the request attribute used to control the max aggregation size of a particular request. |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| protected boolean | |
| public boolean | onConditionsMet(Request
The request to handle request, Response The response to generate response, Callback The callback for completion callback)Implements abstract org. |
| protected boolean | onConditionsNotMet(Request
The request to handle request, Response The response to generate response, Callback The callback for completion callback)Implements abstract org. |
| protected boolean |
| _mimeTypes | back to summary |
|---|---|
| private final IncludeExclude<String> _mimeTypes | |
| BUFFER_SIZE_ATTRIBUTE_NAME | back to summary |
|---|---|
| public static final String BUFFER_SIZE_ATTRIBUTE_NAME The name of the request attribute used to control the buffer size of a particular request. | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG Hides org. | |
| MAX_AGGREGATION_SIZE_ATTRIBUTE_NAME | back to summary |
|---|---|
| public static final String MAX_AGGREGATION_SIZE_ATTRIBUTE_NAME The name of the request attribute used to control the max aggregation size of a particular request. | |
| BufferedResponseHandler | back to summary |
|---|---|
| public BufferedResponseHandler() | |
| BufferedResponseHandler | back to summary |
|---|---|
| public BufferedResponseHandler(Handler handler) | |
| excludeMimeType | back to summary |
|---|---|
| public void excludeMimeType(String... mimeTypes) | |
| includeMimeType | back to summary |
|---|---|
| public void includeMimeType(String... mimeTypes) | |
| isMimeTypeBufferable | back to summary |
|---|---|
| protected boolean isMimeTypeBufferable(String mimetype) | |
| onConditionsMet | back to summary |
|---|---|
| public boolean onConditionsMet(Request request, Response response, Callback callback) throws Exception Implements abstract org. Doc from org. Handle a request that has met the conditions.
Typically, the implementation will provide optional handling and then call the
| |
| onConditionsNotMet | back to summary |
|---|---|
| protected boolean onConditionsNotMet(Request request, Response response, Callback callback) throws Exception Implements abstract org. Doc from org. This method is called when the request has not met the conditions and is not to be handled by this handler. Implementations may return false; send an error response; or handle the request differently. | |
| shouldBuffer | back to summary |
|---|---|
| protected boolean shouldBuffer(Response response, boolean last) | |
| Modifier and Type | Field and Description |
|---|---|
| private Content. | |
| private final Callback | |
| private boolean | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private Content. | |
| public void | failed(Throwable
the reason for the operation failure x)Overrides default org. Callback invoked when the operation fails. |
| public void | succeeded()
Overrides default org. Callback invoked when the operation completes. |
| public void | write(boolean
whether the ByteBuffer is the last to write last, ByteBuffer the ByteBuffer to write byteBuffer, Callback the callback to notify when the write operation is complete callback)Overrides org. Implements org. Writes the given |
| _bufferedContentSink | back to summary |
|---|---|
| private Content. | |
| _callback | back to summary |
|---|---|
| private final Callback _callback | |
| _firstWrite | back to summary |
|---|---|
| private boolean _firstWrite | |
| _lastWritten | back to summary |
|---|---|
| private boolean _lastWritten | |
| BufferedResponse | back to summary |
|---|---|
| private BufferedResponse(Request request, Response response, Callback callback) | |
| createBufferedSink | back to summary |
|---|---|
| private Content. | |
| failed | back to summary |
|---|---|
| public void failed(Throwable x) Overrides default org. Doc from org. Callback invoked when the operation fails. | |
| succeeded | back to summary |
|---|---|
| public void succeeded() Overrides default org. Doc from org. Callback invoked when the operation completes.
| |
| write | back to summary |
|---|---|
| public void write(boolean last, ByteBuffer byteBuffer, Callback callback) Overrides org. Implements org. Doc from org. Writes the given Implementations guarantee that calls to this method are safely reentrant so that
stack overflows are avoided in the case of mutual recursion between the execution of
the The invocation of the passed Thus a
| |