Class HttpChannelState
java.lang.Object
org.eclipse.jetty.server.internal.HttpChannelState
- All Implemented Interfaces:
Components
,HttpChannel
,Invocable
A Channel represents a sequence of request cycles from the same connection with only a single
request cycle may be active at once for each channel.
Many methods return Runnable
s to indicate that further work is needed. These
can be given to an ExecutionStrategy instead of calling known methods like HttpChannel.handle().
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
The Channel's implementation of theResponse
API.Nested classes/interfaces inherited from interface org.eclipse.jetty.server.HttpChannel
HttpChannel.DefaultFactory, HttpChannel.Factory
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task
-
Field Summary
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking, NOOP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addHttpStreamWrapper
(Function<HttpStream, HttpStream> onStreamEvent) getCache()
A Map which can be used as a cache for object (e.g.Returns theRequest
object, if available.void
Initialize the HttpChannel when a new cycle of request handling begins.boolean
onClose()
Notifies thisHttpChannel
that an asynchronous close happened.HttpStream
invokes this method when more HTTP request content is available.Notifies thisHttpChannel
that an asynchronous failure happened.Notifies thisHttpChannel
that an idle timeout happened.onRequest
(MetaData.Request request) Start request handling by returning a Runnable that will callRequest.Handler.handle(Request, Response, Callback)
.void
recycle()
Recycle the HttpChannel, so that a new cycle of callingHttpChannel.setHttpStream(HttpStream)
,HttpChannel.onRequest(MetaData.Request)
etc.void
setHttpStream
(HttpStream stream) Set theHttpStream
to associate to this channel..toString()
-
Constructor Details
-
HttpChannelState
-
-
Method Details
-
initialize
public void initialize()Description copied from interface:HttpChannel
Initialize the HttpChannel when a new cycle of request handling begins.- Specified by:
initialize
in interfaceHttpChannel
- See Also:
-
getComplianceViolationListener
- Specified by:
getComplianceViolationListener
in interfaceHttpChannel
- Returns:
- the active
ComplianceViolation.Listener
-
recycle
public void recycle()Description copied from interface:HttpChannel
Recycle the HttpChannel, so that a new cycle of callingHttpChannel.setHttpStream(HttpStream)
,HttpChannel.onRequest(MetaData.Request)
etc. may be performed on the channel.- Specified by:
recycle
in interfaceHttpChannel
- See Also:
-
getHttpConfiguration
-
getHttpStream
-
setHttpStream
Description copied from interface:HttpChannel
Set theHttpStream
to associate to this channel..- Specified by:
setHttpStream
in interfaceHttpChannel
- Parameters:
stream
- theHttpStream
to associate to this channel.
-
getServer
-
getConnectionMetaData
- Specified by:
getConnectionMetaData
in interfaceHttpChannel
- Returns:
- the
ConnectionMetaData
associated with this channel.
-
getByteBufferPool
- Specified by:
getByteBufferPool
in interfaceComponents
-
getScheduler
- Specified by:
getScheduler
in interfaceComponents
-
getThreadPool
- Specified by:
getThreadPool
in interfaceComponents
-
getCache
Description copied from interface:Components
A Map which can be used as a cache for object (e.g. Cookie cache). The cache will have a life cycle limited by the connection, i.e. no cache map will live longer that the connection associated with it. However, a cache may have a shorter life than a connection (e.g. it may be discarded for implementation reasons). A cache map is guaranteed to be given to only a single request concurrently (scoped byHttpChannelState
), so objects saved there do not need to be made safe from access by simultaneous request. If the connection is known to be none-persistent then the cache may be a noop cache and discard all items set on it.- Specified by:
getCache
in interfaceComponents
- Returns:
- A Map, which may be an empty map that discards all items.
-
onRequest
Start request handling by returning a Runnable that will callRequest.Handler.handle(Request, Response, Callback)
.- Specified by:
onRequest
in interfaceHttpChannel
- Parameters:
request
- The request metadata to handle.- Returns:
- A Runnable that will call
Request.Handler.handle(Request, Response, Callback)
. Unlike all otherRunnable
s returned by HttpChannel methods, this runnable should not be mutually excluded or serialized. Specifically otherRunnable
s returned by methods on this class can be run concurrently with theRunnable
returned from this method.
-
getRequest
Description copied from interface:HttpChannel
Returns the
Request
object, if available.The
Request
object is only available after a call toHttpChannel.onRequest(MetaData.Request)
has been made.- Specified by:
getRequest
in interfaceHttpChannel
- Returns:
- the
Request
object, or null if theRequest
object is not yet available.
-
getResponse
-
isRequestHandled
public boolean isRequestHandled()- Specified by:
isRequestHandled
in interfaceHttpChannel
- Returns:
- whether the request has been passed to the root
Handler
.
-
onContentAvailable
Description copied from interface:HttpChannel
HttpStream
invokes this method when more HTTP request content is available.- Specified by:
onContentAvailable
in interfaceHttpChannel
- Returns:
- the last
Runnable
passed toRequest.demand(Runnable)
, ornull
if there is no demand for content.
-
getInvocationType
- Specified by:
getInvocationType
in interfaceInvocable
- Returns:
- The InvocationType of this object
-
onIdleTimeout
Description copied from interface:HttpChannel
Notifies this
HttpChannel
that an idle timeout happened.- Specified by:
onIdleTimeout
in interfaceHttpChannel
- Parameters:
t
- the timeout.- Returns:
- a
Runnable
that performs the timeout action, ornull
if no action need be performed by the calling thread - See Also:
-
onFailure
Description copied from interface:HttpChannel
Notifies this
HttpChannel
that an asynchronous failure happened.Typical failure examples could be HTTP/2 resets or protocol failures (for example, invalid request bytes).
- Specified by:
onFailure
in interfaceHttpChannel
- Parameters:
x
- the failure cause.- Returns:
- a
Runnable
that performs the failure action, ornull
if no failure action needs be performed by the calling thread - See Also:
-
onClose
Description copied from interface:HttpChannel
Notifies this
HttpChannel
that an asynchronous close happened.- Specified by:
onClose
in interfaceHttpChannel
- Returns:
- a
Runnable
that performs the close action, ornull
if no close action needs be performed by the calling thread
-
addHttpStreamWrapper
-
toString
-