Interface HttpStream
- All Known Implementing Classes:
HttpStream.Wrapper
MetaData.Request, represents the
flow of data from and to a single request and response cycle. It is roughly analogous to the
Stream within an HTTP/2 connection, in that a connection can have many streams, each used once
and each representing a single request and response exchange.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface Callback
Callback.Completable, Callback.Completing, Callback.NestedNested classes/interfaces inherited from interface Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Exceptionstatic final StringAttribute name to be used as aRequestattribute to store/retrieve theConnectioncreated during the HTTP/1.1 upgrade mechanism or the HTTP/2 tunnel mechanism.Fields inherited from interface Invocable
__nonBlocking -
Method Summary
Modifier and TypeMethodDescriptionstatic ThrowableconsumeAvailable(HttpStream stream, HttpConfiguration httpConfig) voiddemand()Demands more content chunks to the underlying implementation.getId()longdefault Invocable.InvocationTypedefault TunnelSupportbooleanvoidprepareResponse(HttpFields.Mutable headers) Prepare the response headers with respect to the stream.default voidpush(MetaData.Request resource) Pushes the givenresourceto the client.read()Reads a chunk of content, with the same semantic asContent.Source.read().voidsend(MetaData.Request request, MetaData.Response response, boolean last, ByteBuffer content, Callback callback) Send response meta-data and/or data.voidsetIdleTimeout(long idleTimeoutMs) Methods inherited from interface Callback
completeWith, failed, succeeded
-
Field Details
-
CONTENT_NOT_CONSUMED
-
UPGRADE_CONNECTION_ATTRIBUTE
Attribute name to be used as a
Requestattribute to store/retrieve theConnectioncreated during the HTTP/1.1 upgrade mechanism or the HTTP/2 tunnel mechanism.
-
-
Method Details
-
getId
String getId()- Returns:
- an ID unique within the lifetime scope of the associated protocol connection. This may be a protocol ID (e.g. HTTP/2 stream ID) or it may be unrelated to the protocol.
-
read
Content.Chunk read()Reads a chunk of content, with the same semantic as
Content.Source.read().This method is called from the implementation of
Request.read().- Returns:
- a chunk of content, possibly with non-null
Content.Chunk.getFailure()ornull.
-
demand
void demand()Demands more content chunks to the underlying implementation.
This method is called from the implementation of
Request.demand(Runnable)and when the demand can be satisfied the implementation must callHttpChannel.onContentAvailable(). If there is a problem meeting demand, then the implementation must callHttpChannel.onFailure(Throwable).- See Also:
-
prepareResponse
Prepare the response headers with respect to the stream. Typically this may set headers related to protocol specific behaviour (e.g.
Keep-Alivefor HTTP/1.0 connections).- Parameters:
headers- The headers to prepare.
-
send
void send(MetaData.Request request, MetaData.Response response, boolean last, ByteBuffer content, Callback callback) Send response meta-data and/or data.
- Parameters:
request- The request metadata for which the response should be sent.response- The response metadata to be sent or null if the response is already committed by a previous call to send.last- True if this will be the last call to send and the response can be completed.content- A buffer of content to send or null if no content.callback- The callback to invoke when the send is completed successfully or in failure.
-
push
Pushes the given
resourceto the client.- Parameters:
resource- the resource to push- Throws:
UnsupportedOperationException- if the push functionality is not supported- See Also:
-
getIdleTimeout
long getIdleTimeout() -
setIdleTimeout
void setIdleTimeout(long idleTimeoutMs) -
isCommitted
boolean isCommitted() -
getTunnelSupport
-
consumeAvailable
Throwable consumeAvailable() -
consumeAvailable
-
getInvocationType
- Specified by:
getInvocationTypein interfaceInvocable- Returns:
- The InvocationType of this object
-