Class ContextRequest
- All Implemented Interfaces:
Content.Source
,Request
,Attributes
,Invocable
- Direct Known Subclasses:
ServletContextRequest
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Attributes
Attributes.Layer, Attributes.Lazy, Attributes.Mapped, Attributes.Synthetic
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.server.Request
Request.AttributesWrapper, Request.AuthenticationState, Request.Handler, Request.ServeAs, Request.Wrapper
-
Field Summary
Fields inherited from interface org.eclipse.jetty.util.Attributes
NULL
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking, NOOP
Fields inherited from interface org.eclipse.jetty.server.Request
COOKIE_ATTRIBUTE, DEFAULT_LOCALES
-
Constructor Summary
ModifierConstructorDescriptionprotected
ContextRequest
(ContextHandler.ScopedContext context, Request request) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFailureListener
(Consumer<Throwable> onFailure) Adds a listener for asynchronous fatal failures.void
addIdleTimeoutListener
(Predicate<TimeoutException> onIdleTimeout) Adds a listener for idle timeouts.void
Demands to invoke the given demand callback parameter when a chunk of content is available.Get theContext
associated with thisRequest
.Methods inherited from class org.eclipse.jetty.server.Request.Wrapper
addHttpStreamWrapper, asAttributeMap, clearAttributes, consumeAvailable, fail, getAttribute, getAttributeNameSet, getBeginNanoTime, getComponents, getConnectionMetaData, getHeaders, getHeadersNanoTime, getHttpURI, getId, getLength, getMethod, getSession, getTrailers, getTunnelSupport, getWrapped, isSecure, push, read, removeAttribute, setAttribute, 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.Attributes
equals, hashCode
Methods inherited from interface org.eclipse.jetty.io.Content.Source
fail, rewind
Methods inherited from interface org.eclipse.jetty.util.thread.Invocable
getInvocationType
-
Constructor Details
-
ContextRequest
-
-
Method Details
-
demand
Description copied from interface:Request
Demands to invoke the given demand callback parameter when a chunk of content is available.
See how to use this method idiomatically.
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
Runnable
callback and a call to this method. Invocations of the passedRunnable
are serialized and a callback fordemand
call is not invoked until any previousdemand
callback has returned. Thus theRunnable
should not block waiting for a callback of a future demand call.The demand callback may be invoked spuriously: a subsequent call to
Content.Source.read()
may returnnull
.Calling this method establishes a pending demand, which is fulfilled when the demand callback is invoked.
Calling this method when there is already a pending demand results in an
IllegalStateException
to be thrown.If the invocation of the demand callback throws an exception, then
Content.Source.fail(Throwable)
is called.- Specified by:
demand
in interfaceContent.Source
- Specified by:
demand
in interfaceRequest
- Overrides:
demand
in classRequest.Wrapper
- Parameters:
demandCallback
- the demand callback to invoke when there is a content chunk available.- See Also:
-
addIdleTimeoutListener
Description copied from interface:Request
Adds a listener for idle timeouts.
The listener is a predicate function that should return
true
to indicate that the idle timeout should be handled by the container as a fatal failure (seeRequest.addFailureListener(Consumer)
); orfalse
to ignore that specific timeout and for another timeout to occur after another idle period.Idle timeout listeners are only invoked if there are no pending
Request.demand(Runnable)
orResponse.write(boolean, ByteBuffer, Callback)
operations.Listeners are processed in the same order they are added, and the first that returns
true
stops the processing of subsequent listeners, which are therefore not invoked.- Specified by:
addIdleTimeoutListener
in interfaceRequest
- Overrides:
addIdleTimeoutListener
in classRequest.Wrapper
- Parameters:
onIdleTimeout
- the idle timeout listener as a predicate function- See Also:
-
addFailureListener
Description copied from interface:Request
Adds a listener for asynchronous fatal failures.
When a listener is called, the effects of the failure have already taken place:
- Pending
Request.demand(Runnable)
have been woken up. - Calls to
Request.read()
will return theThrowable
failure. - Pending and new
Response.write(boolean, ByteBuffer, Callback)
calls will be failed by callingCallback.failed(Throwable)
on the callback passed toResponse.write(boolean, ByteBuffer, Callback)
.
Listeners are processed in the same order they are added.
- Specified by:
addFailureListener
in interfaceRequest
- Overrides:
addFailureListener
in classRequest.Wrapper
- Parameters:
onFailure
- the failure listener as a consumer function- See Also:
- Pending
-
getContext
Description copied from interface:Request
Get theContext
associated with thisRequest
.Note that a
Request
should always have an associatedContext
since if theRequest
is not being handled by aContextHandler
then theContext
fromServer.getContext()
will be used.- Specified by:
getContext
in interfaceRequest
- Overrides:
getContext
in classRequest.Wrapper
- Returns:
- the
Context
associated with thisRequest
. Nevernull
. - See Also:
-