Stream

<p> A {@link Stream} represents a bidirectional exchange of data on top of a {@link Session}. </p> <p> Differently from socket streams, where the input and output streams are permanently associated with the socket (and hence with the connection that the socket represents), there can be multiple HTTP/2 streams present concurrent for a HTTP/2 session. </p> <p> A {@link Stream} maps to a HTTP request/response cycle, and after the request/response cycle is completed, the stream is closed and removed from the session. </p> <p> Like {@link Session}, {@link Stream} is the active part and by calling its API applications can generate events on the stream; conversely, {@link Stream.Listener} is the passive part, and its callbacks are invoked when events happen on the stream. </p>

@see Stream.Listener

Members

Functions

data
void data(DataFrame frame, Callback callback)

<p>Sends the given DATA {@code frame}.</p>

getAttribute
Object getAttribute(string key)

@param key the attribute key @return an arbitrary object associated with the given key to this stream or null if no object can be found for the given key. @see #setAttribute(string, Object)

getId
int getId()

@return the stream unique id

getSession
Session getSession()

@return the session this stream is associated to

headers
void headers(HeadersFrame frame, Callback callback)

<p>Sends the given HEADERS {@code frame} representing a HTTP response.</p>

isClosed
bool isClosed()

@return whether this stream is closed, both locally and remotely.

isReset
bool isReset()

@return whether this stream has been reset

push
void push(PushPromiseFrame frame, Promise!Stream promise, Listener listener)

<p>Sends the given PUSH_PROMISE {@code frame}.</p>

removeAttribute
Object removeAttribute(string key)

@param key the attribute key @return the arbitrary object associated with the given key to this stream @see #setAttribute(string, Object)

reset
void reset(ResetFrame frame, Callback callback)

<p>Sends the given RST_STREAM {@code frame}.</p>

setAttribute
void setAttribute(string key, Object value)

@param key the attribute key @param value an arbitrary object to associate with the given key to this stream @see #getAttribute(string) @see #removeAttribute(string)

toString
string toString()

@param idleTimeout the stream idle timeout @see #getIdleTimeout() @see Stream.Listener#onIdleTimeout(Stream, Exception)

Interfaces

Listener
interface Listener

<p>A {@link Stream.Listener} is the passive counterpart of a {@link Stream} and receives events happening on a HTTP/2 stream.</p>

Meta