public interface Stream
A Stream
represents a bidirectional exchange of data on top of a Session
.
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.
A 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.
Like Session
, Stream
is the active part and by calling its API applications
can generate events on the stream; conversely, Stream.Listener
is the passive part, and
its callbacks are invoked when events happen on the stream.
Stream.Listener
Modifier and Type | Interface and Description |
---|---|
static interface |
Stream.Listener
A
Stream.Listener is the passive counterpart of a Stream and receives
events happening on a HTTP/2 stream. |
Modifier and Type | Method and Description |
---|---|
void |
data(DataFrame frame,
Callback callback)
Sends the given DATA
frame . |
Object |
getAttribute(String key) |
int |
getId() |
long |
getIdleTimeout() |
Session |
getSession() |
void |
headers(HeadersFrame frame,
Callback callback)
Sends the given HEADERS
frame representing a HTTP response. |
boolean |
isClosed() |
boolean |
isReset() |
void |
push(PushPromiseFrame frame,
Promise<Stream> promise,
Stream.Listener listener)
Sends the given PUSH_PROMISE
frame . |
Object |
removeAttribute(String key) |
void |
reset(ResetFrame frame,
Callback callback)
Sends the given RST_STREAM
frame . |
void |
setAttribute(String key,
Object value) |
void |
setIdleTimeout(long idleTimeout) |
int getId()
Session getSession()
void headers(HeadersFrame frame, Callback callback)
Sends the given HEADERS frame
representing a HTTP response.
frame
- the HEADERS frame to sendcallback
- the callback that gets notified when the frame has been sentvoid push(PushPromiseFrame frame, Promise<Stream> promise, Stream.Listener listener)
Sends the given PUSH_PROMISE frame
.
frame
- the PUSH_PROMISE frame to sendpromise
- the promise that gets notified of the pushed stream creationlistener
- the listener that gets notified of stream eventsvoid data(DataFrame frame, Callback callback)
Sends the given DATA frame
.
frame
- the DATA frame to sendcallback
- the callback that gets notified when the frame has been sentvoid reset(ResetFrame frame, Callback callback)
Sends the given RST_STREAM frame
.
frame
- the RST_FRAME to sendcallback
- the callback that gets notified when the frame has been sentObject getAttribute(String key)
key
- the attribute keysetAttribute(String, Object)
void setAttribute(String key, Object value)
key
- the attribute keyvalue
- an arbitrary object to associate with the given key to this streamgetAttribute(String)
,
removeAttribute(String)
Object removeAttribute(String key)
key
- the attribute keysetAttribute(String, Object)
boolean isReset()
boolean isClosed()
long getIdleTimeout()
setIdleTimeout(long)
void setIdleTimeout(long idleTimeout)
idleTimeout
- the stream idle timeoutgetIdleTimeout()
,
Stream.Listener.onTimeout(Stream, Throwable)
Copyright © 1995-2016 Webtide. All Rights Reserved.