Interface HttpChannel
- All Superinterfaces:
Invocable
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
Nested ClassesModifier and TypeInterfaceDescriptionstatic classThe factory that creates default implementations ofHttpChannel.static interfaceA factory forHttpChannelinstances.Nested classes/interfaces inherited from interface Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task -
Field Summary
Fields inherited from interface Invocable
__nonBlocking, NOOP -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpChannelReturns theRequestobject, if available.voidInitialize the HttpChannel when a new cycle of request handling begins.booleandefault RunnableonClose()Notifies thisHttpChannelthat an asynchronous close happened.HttpStreaminvokes this method when more HTTP request content is available.Notifies thisHttpChannelthat an asynchronous failure happened.onIdleTimeout(TimeoutException idleTimeout) Notifies thisHttpChannelthat an idle timeout happened.onRemoteFailure(Throwable failure) Notifies thisHttpChannelthat an asynchronous notification was received indicating a remote failure happened.onRequest(MetaData.Request metaData) HttpStreaminvokes this method when the metadata of an HTTP request (method, URI and headers, but not content) has been parsed.voidrecycle()Recycle the HttpChannel, so that a new cycle of callingsetHttpStream(HttpStream),onRequest(MetaData.Request)etc. may be performed on the channel.voidsetHttpStream(HttpStream httpStream) Set theHttpStreamto associate to this channel..Methods inherited from interface Invocable
getInvocationType
-
Method Details
-
getConnectionMetaData
ConnectionMetaData getConnectionMetaData()- Returns:
- the
ConnectionMetaDataassociated with this channel.
-
setHttpStream
Set theHttpStreamto associate to this channel..- Parameters:
httpStream- theHttpStreamto associate to this channel.
-
isRequestHandled
boolean isRequestHandled()- Returns:
- whether the request has been passed to the root
Handler.
-
onRequest
HttpStreaminvokes this method when the metadata of an HTTP request (method, URI and headers, but not content) has been parsed.The returned
Runnableinvokes the rootHandler.- Parameters:
metaData- the HTTP request metadata.- Returns:
- a
Runnablethat invokes the rootHandler.
-
getRequest
Request getRequest()Returns the
Requestobject, if available.The
Requestobject is only available after a call toonRequest(MetaData.Request)has been made.- Returns:
- the
Requestobject, or null if theRequestobject is not yet available.
-
onContentAvailable
Runnable onContentAvailable()HttpStreaminvokes this method when more HTTP request content is available.- Returns:
- the last
Runnablepassed toRequest.demand(Runnable), ornullif there is no demand for content.
-
onIdleTimeout
Notifies this
HttpChannelthat an idle timeout happened.- Parameters:
idleTimeout- the timeout.- Returns:
- a
Runnablethat performs the timeout action, ornullif no action need be performed by the calling thread - See Also:
-
onFailure
Notifies this
HttpChannelthat an asynchronous failure happened.Typical failure examples could be protocol failures (for example, invalid request bytes).
- Parameters:
failure- the failure cause.- Returns:
- a
Runnablethat performs the failure action, ornullif no failure action needs be performed by the calling thread - See Also:
-
onRemoteFailure
Notifies this
HttpChannelthat 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
Runnablethat performs the failure action, ornullif no failure action needs be performed by the calling thread - See Also:
-
onClose
Notifies this
HttpChannelthat an asynchronous close happened.- Returns:
- a
Runnablethat performs the close action, ornullif 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
-