-
- All Known Implementing Classes:
Stream.Listener.Adapter
- Enclosing interface:
- Stream
public static interface Stream.ListenerA
Stream.Listeneris the passive counterpart of aStreamand receives events happening on an HTTP/2 stream.HTTP/2 data is flow controlled - this means that only a finite number of data events are delivered, until the flow control window is exhausted.
Applications control the delivery of data events by requesting them via
Stream.demand(long); the first event is always delivered, while subsequent events must be explicitly demanded.Applications control the HTTP/2 flow control by completing the callback associated with data events - this allows the implementation to recycle the data buffer and eventually to enlarge the flow control window so that the sender can send more data.
- See Also:
Stream
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classStream.Listener.AdapterEmpty implementation ofStream.Listener
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidonBeforeData(Stream stream)Callback method invoked before notifying the first DATA frame.default voidonClosed(Stream stream)Callback method invoked after the stream has been closed.default voidonData(Stream stream, DataFrame frame, org.eclipse.jetty.util.Callback callback)Callback method invoked when a DATA frame has been received.default voidonDataDemanded(Stream stream, DataFrame frame, org.eclipse.jetty.util.Callback callback)Callback method invoked when a DATA frame has been demanded.default voidonFailure(Stream stream, int error, java.lang.String reason, java.lang.Throwable failure, org.eclipse.jetty.util.Callback callback)Callback method invoked when the stream failed.voidonHeaders(Stream stream, HeadersFrame frame)Callback method invoked when a HEADERS frame representing the HTTP response has been received.booleanonIdleTimeout(Stream stream, java.lang.Throwable x)Callback method invoked when the stream exceeds its idle timeout.default voidonNewStream(Stream stream)Callback method invoked when a stream is created locally bySession.newStream(HeadersFrame, Promise, Listener).Stream.ListeneronPush(Stream stream, PushPromiseFrame frame)Callback method invoked when a PUSH_PROMISE frame has been received.default voidonReset(Stream stream, ResetFrame frame)Callback method invoked when a RST_STREAM frame has been received for this stream.default voidonReset(Stream stream, ResetFrame frame, org.eclipse.jetty.util.Callback callback)Callback method invoked when a RST_STREAM frame has been received for this stream.
-
-
-
Method Detail
-
onNewStream
default void onNewStream(Stream stream)
Callback method invoked when a stream is created locally by
Session.newStream(HeadersFrame, Promise, Listener).- Parameters:
stream- the newly created stream
-
onHeaders
void onHeaders(Stream stream, HeadersFrame frame)
Callback method invoked when a HEADERS frame representing the HTTP response has been received.
- Parameters:
stream- the streamframe- the HEADERS frame received
-
onPush
Stream.Listener onPush(Stream stream, PushPromiseFrame frame)
Callback method invoked when a PUSH_PROMISE frame has been received.
- Parameters:
stream- the pushed streamframe- the PUSH_PROMISE frame received- Returns:
- a Stream.Listener that will be notified of pushed stream events
-
onBeforeData
default void onBeforeData(Stream stream)
Callback method invoked before notifying the first DATA frame.
The default implementation initializes the demand for DATA frames.
- Parameters:
stream- the stream
-
onData
default void onData(Stream stream, DataFrame frame, org.eclipse.jetty.util.Callback callback)
Callback method invoked when a DATA frame has been received.
- Parameters:
stream- the streamframe- the DATA frame receivedcallback- the callback to complete when the bytes of the DATA frame have been consumed- See Also:
onDataDemanded(Stream, DataFrame, Callback)
-
onDataDemanded
default void onDataDemanded(Stream stream, DataFrame frame, org.eclipse.jetty.util.Callback callback)
Callback method invoked when a DATA frame has been demanded.
Implementations of this method must arrange to call (within the method or otherwise asynchronously)
Stream.demand(long).- Parameters:
stream- the streamframe- the DATA frame receivedcallback- the callback to complete when the bytes of the DATA frame have been consumed
-
onReset
default void onReset(Stream stream, ResetFrame frame, org.eclipse.jetty.util.Callback callback)
Callback method invoked when a RST_STREAM frame has been received for this stream.
- Parameters:
stream- the streamframe- the RST_FRAME receivedcallback- the callback to complete when the reset has been handled
-
onReset
default void onReset(Stream stream, ResetFrame frame)
Callback method invoked when a RST_STREAM frame has been received for this stream.
- Parameters:
stream- the streamframe- the RST_FRAME received- See Also:
Session.Listener.onReset(Session, ResetFrame)
-
onIdleTimeout
boolean onIdleTimeout(Stream stream, java.lang.Throwable x)
Callback method invoked when the stream exceeds its idle timeout.
- Parameters:
stream- the streamx- the timeout failure- Returns:
- true to reset the stream, false to ignore the idle timeout
- See Also:
Stream.getIdleTimeout()
-
onFailure
default void onFailure(Stream stream, int error, java.lang.String reason, java.lang.Throwable failure, org.eclipse.jetty.util.Callback callback)
Callback method invoked when the stream failed.
- Parameters:
stream- the streamerror- the error codereason- the error reason, or nullfailure- the failurecallback- the callback to complete when the failure has been handled
-
onClosed
default void onClosed(Stream stream)
Callback method invoked after the stream has been closed.
- Parameters:
stream- the stream
-
-