-
- All Known Subinterfaces:
IStream
- All Known Implementing Classes:
HTTP2Stream
public interface StreamA
Streamrepresents a bidirectional exchange of data on top of aSession.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 concurrently for an HTTP/2 session.
A
Streammaps to an HTTP request/response cycle, and after the request/response cycle is completed, the stream is closed and removed from the session.Like
Session,Streamis the active part and by calling its API applications can generate events on the stream; conversely,Stream.Listeneris the passive part, and its callbacks are invoked when events happen on the stream.- See Also:
Stream.Listener
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceStream.ListenerAStream.Listeneris the passive counterpart of aStreamand receives events happening on an HTTP/2 stream.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.concurrent.CompletableFuture<Stream>data(DataFrame frame)Sends the given DATAframe.voiddata(DataFrame frame, org.eclipse.jetty.util.Callback callback)Sends the given DATAframe.voiddemand(long n)DemandsnmoreDATAframes for this stream.java.lang.ObjectgetAttribute(java.lang.String key)intgetId()longgetIdleTimeout()SessiongetSession()default java.util.concurrent.CompletableFuture<Stream>headers(HeadersFrame frame)Sends the given HEADERSframerepresenting an HTTP response.voidheaders(HeadersFrame frame, org.eclipse.jetty.util.Callback callback)Sends the given HEADERSframe.booleanisClosed()booleanisReset()default java.util.concurrent.CompletableFuture<Stream>push(PushPromiseFrame frame, Stream.Listener listener)Sends the given PUSH_PROMISEframe.voidpush(PushPromiseFrame frame, org.eclipse.jetty.util.Promise<Stream> promise, Stream.Listener listener)Sends the given PUSH_PROMISEframe.java.lang.ObjectremoveAttribute(java.lang.String key)voidreset(ResetFrame frame, org.eclipse.jetty.util.Callback callback)Sends the given RST_STREAMframe.voidsetAttribute(java.lang.String key, java.lang.Object value)voidsetIdleTimeout(long idleTimeout)
-
-
-
Method Detail
-
getId
int getId()
- Returns:
- the stream unique id
-
getSession
Session getSession()
- Returns:
- the session this stream is associated to
-
headers
default java.util.concurrent.CompletableFuture<Stream> headers(HeadersFrame frame)
Sends the given HEADERS
framerepresenting an HTTP response.- Parameters:
frame- the HEADERS frame to send- Returns:
- the CompletableFuture that gets notified when the frame has been sent
-
headers
void headers(HeadersFrame frame, org.eclipse.jetty.util.Callback callback)
Sends the given HEADERS
frame.Typically used to send an HTTP response or to send the HTTP response trailers.
- Parameters:
frame- the HEADERS frame to sendcallback- the callback that gets notified when the frame has been sent
-
push
default java.util.concurrent.CompletableFuture<Stream> push(PushPromiseFrame frame, Stream.Listener listener)
Sends the given PUSH_PROMISE
frame.- Parameters:
frame- the PUSH_PROMISE frame to sendlistener- the listener that gets notified of stream events- Returns:
- the CompletableFuture that gets notified of the pushed stream creation
-
push
void push(PushPromiseFrame frame, org.eclipse.jetty.util.Promise<Stream> promise, Stream.Listener listener)
Sends the given PUSH_PROMISE
frame.- Parameters:
frame- the PUSH_PROMISE frame to sendpromise- the promise that gets notified of the pushed stream creationlistener- the listener that gets notified of stream events
-
data
default java.util.concurrent.CompletableFuture<Stream> data(DataFrame frame)
Sends the given DATA
frame.- Parameters:
frame- the DATA frame to send- Returns:
- the CompletableFuture that gets notified when the frame has been sent
-
data
void data(DataFrame frame, org.eclipse.jetty.util.Callback callback)
Sends the given DATA
frame.- Parameters:
frame- the DATA frame to sendcallback- the callback that gets notified when the frame has been sent
-
reset
void reset(ResetFrame frame, org.eclipse.jetty.util.Callback callback)
Sends the given RST_STREAM
frame.- Parameters:
frame- the RST_FRAME to sendcallback- the callback that gets notified when the frame has been sent
-
getAttribute
java.lang.Object getAttribute(java.lang.String key)
- Parameters:
key- the attribute key- Returns:
- an arbitrary object associated with the given key to this stream or null if no object can be found for the given key.
- See Also:
setAttribute(String, Object)
-
setAttribute
void setAttribute(java.lang.String key, java.lang.Object value)- Parameters:
key- the attribute keyvalue- an arbitrary object to associate with the given key to this stream- See Also:
getAttribute(String),removeAttribute(String)
-
removeAttribute
java.lang.Object removeAttribute(java.lang.String key)
- Parameters:
key- the attribute key- Returns:
- the arbitrary object associated with the given key to this stream
- See Also:
setAttribute(String, Object)
-
isReset
boolean isReset()
- Returns:
- whether this stream has been reset
-
isClosed
boolean isClosed()
- Returns:
- whether this stream is closed, both locally and remotely.
-
getIdleTimeout
long getIdleTimeout()
- Returns:
- the stream idle timeout
- See Also:
setIdleTimeout(long)
-
setIdleTimeout
void setIdleTimeout(long idleTimeout)
- Parameters:
idleTimeout- the stream idle timeout- See Also:
getIdleTimeout(),Stream.Listener.onIdleTimeout(Stream, Throwable)
-
demand
void demand(long n)
Demands
nmoreDATAframes for this stream.- Parameters:
n- the increment of the demand, must be greater than zero- See Also:
Stream.Listener.onDataDemanded(Stream, DataFrame, Callback)
-
-