Interface HttpChannel
- All Superinterfaces:
Invocable
- All Known Implementing Classes:
HttpChannelState
Represents the state of an HTTP request/response cycle.
HttpChannel
links the lower (closer to the network) layer HttpStream
with the upper (application code) layer Handler
.
An HttpChannel
instance may be used for many HTTP request/response cycles
from the same connection; however, only a single cycle may be active at any time.
Default implementations of this interface may be created via HttpChannel.DefaultFactory
.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
The factory that creates default implementations ofHttpChannel
.static interface
A factory forHttpChannel
instances.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
-
Method Summary
Modifier and TypeMethodDescriptionstatic HttpChannel
Returns theRequest
object, if available.void
Initialize the HttpChannel when a new cycle of request handling begins.boolean
default Runnable
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.onIdleTimeout
(TimeoutException idleTimeout) Notifies thisHttpChannel
that an idle timeout happened.onRemoteFailure
(Throwable failure) Notifies thisHttpChannel
that an asynchronous notification was received indicating a remote failure happened.onRequest
(MetaData.Request metaData) HttpStream
invokes this method when the metadata of an HTTP request (method, URI and headers, but not content) has been parsed.void
recycle()
Recycle the HttpChannel, so that a new cycle of callingsetHttpStream(HttpStream)
,onRequest(MetaData.Request)
etc.void
setHttpStream
(HttpStream httpStream) Set theHttpStream
to associate to this channel..Methods inherited from interface org.eclipse.jetty.util.thread.Invocable
getInvocationType
-
Method Details
-
getConnectionMetaData
ConnectionMetaData getConnectionMetaData()- Returns:
- the
ConnectionMetaData
associated with this channel.
-
setHttpStream
Set theHttpStream
to associate to this channel..- Parameters:
httpStream
- theHttpStream
to associate to this channel.
-
isRequestHandled
boolean isRequestHandled()- Returns:
- whether the request has been passed to the root
Handler
.
-
onRequest
HttpStream
invokes this method when the metadata of an HTTP request (method, URI and headers, but not content) has been parsed.The returned
Runnable
invokes the rootHandler
.- Parameters:
metaData
- the HTTP request metadata.- Returns:
- a
Runnable
that invokes the rootHandler
.
-
getRequest
Request getRequest()Returns the
Request
object, if available.The
Request
object is only available after a call toonRequest(MetaData.Request)
has been made.- Returns:
- the
Request
object, or null if theRequest
object is not yet available.
-
onContentAvailable
Runnable onContentAvailable()HttpStream
invokes this method when more HTTP request content is available.- Returns:
- the last
Runnable
passed toRequest.demand(Runnable)
, ornull
if there is no demand for content.
-
onIdleTimeout
Notifies this
HttpChannel
that an idle timeout happened.- Parameters:
idleTimeout
- the timeout.- Returns:
- a
Runnable
that performs the timeout action, ornull
if no action need be performed by the calling thread - See Also:
-
onFailure
Notifies this
HttpChannel
that an asynchronous failure happened.Typical failure examples could be protocol failures (for example, invalid request bytes).
- Parameters:
failure
- 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:
-
onRemoteFailure
Notifies this
HttpChannel
that an asynchronous notification was received indicating a remote failure happened.Typical failure examples could be HTTP/2 resets.
- Parameters:
failure
- 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
Notifies this
HttpChannel
that an asynchronous close happened.- Returns:
- a
Runnable
that performs the close action, ornull
if no close action needs be performed by the calling thread
-
recycle
void recycle()Recycle the HttpChannel, so that a new cycle of callingsetHttpStream(HttpStream)
,onRequest(MetaData.Request)
etc. may be performed on the channel.- See Also:
-
initialize
void initialize()Initialize the HttpChannel when a new cycle of request handling begins.- See Also:
-
getComplianceViolationListener
ComplianceViolation.Listener getComplianceViolationListener()- Returns:
- the active
ComplianceViolation.Listener
-
from
- Parameters:
request
- attempt to resolve the HttpChannel from the provided request- Returns:
- the HttpChannel if found
- Throws:
IllegalStateException
- if unable to find HttpChannel
-