Class BufferedResponseHandler
- All Implemented Interfaces:
Handler
,Handler.Container
,Handler.Singleton
,Request.Handler
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
,Invocable
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.server.handler.ConditionalHandler
ConditionalHandler.Abstract, ConditionalHandler.ConnectorPredicate, ConditionalHandler.DontHandle, ConditionalHandler.ElseNext, ConditionalHandler.InetAddressPatternPredicate, ConditionalHandler.MethodPredicate, ConditionalHandler.PathSpecPredicate, ConditionalHandler.PredicateSet, ConditionalHandler.Reject, ConditionalHandler.SkipNext
Nested classes/interfaces inherited from class org.eclipse.jetty.server.Handler.Abstract
Handler.Abstract.NonBlocking
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopException
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Handler
Handler.AbstractContainer, Handler.Collection, Handler.Container, Handler.Sequence, Handler.Singleton, Handler.Wrapper
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Request.Handler
Request.Handler.AbortException
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The name of the request attribute used to control the buffer size of a particular request.static final String
The name of the request attribute used to control the max aggregation size of a particular request.Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, STARTED, STARTING, STOPPED, STOPPING
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking, NOOP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
excludeMimeType
(String... mimeTypes) void
includeMimeType
(String... mimeTypes) protected boolean
isMimeTypeBufferable
(String mimetype) boolean
onConditionsMet
(Request request, Response response, Callback callback) Handle a request that has met the conditions.protected boolean
onConditionsNotMet
(Request request, Response response, Callback callback) This method is called when the request has not met the conditions and is not to be handled by this handler.protected boolean
shouldBuffer
(Response response, boolean last) Methods inherited from class org.eclipse.jetty.server.handler.ConditionalHandler
clear, doStart, dump, exclude, exclude, exclude, excludeInetAddressPattern, excludeMethod, excludePath, from, from, handle, include, include, include, includeInetAddressPattern, includeMethod, includePath, nextHandler
Methods inherited from class org.eclipse.jetty.server.Handler.Wrapper
getHandler, getInvocationType, setHandler
Methods inherited from class org.eclipse.jetty.server.Handler.AbstractContainer
findContainerOf, getDescendant, getDescendants, isDynamic, setDynamic, setServer
Methods inherited from class org.eclipse.jetty.server.Handler.Abstract
destroy, doStop, getServer
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListeners
Methods inherited from interface org.eclipse.jetty.util.component.Destroyable
destroy
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.server.Handler.Container
getContainer, getDescendant, getDescendants, getDescendants
Methods inherited from interface org.eclipse.jetty.server.Handler.Singleton
getHandlers, getTail, insertHandler, setHandler
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addEventListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, start, stop
-
Field Details
-
BUFFER_SIZE_ATTRIBUTE_NAME
The name of the request attribute used to control the buffer size of a particular request. -
MAX_AGGREGATION_SIZE_ATTRIBUTE_NAME
The name of the request attribute used to control the max aggregation size of a particular request.
-
-
Constructor Details
-
BufferedResponseHandler
public BufferedResponseHandler() -
BufferedResponseHandler
-
-
Method Details
-
includeMimeType
-
excludeMimeType
-
isMimeTypeBufferable
-
shouldBuffer
-
onConditionsMet
public boolean onConditionsMet(Request request, Response response, Callback callback) throws Exception Description copied from class:ConditionalHandler
Handle a request that has met the conditions. Typically, the implementation will provide optional handling and then call theConditionalHandler.nextHandler(Request, Response, Callback)
method to continue handling.- Specified by:
onConditionsMet
in classConditionalHandler
- Parameters:
request
- The request to handleresponse
- The response to generatecallback
- The callback for completion- Returns:
- True if this handler will complete the callback
- Throws:
Exception
- If there is a problem handling- See Also:
-
onConditionsNotMet
protected boolean onConditionsNotMet(Request request, Response response, Callback callback) throws Exception Description copied from class:ConditionalHandler
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.- Specified by:
onConditionsNotMet
in classConditionalHandler
- Parameters:
request
- The request to handleresponse
- The response to generatecallback
- The callback for completion- Returns:
- True if this handler will complete the callback
- Throws:
Exception
- If there is a problem handling- See Also:
-