Class HTTP2ServerConnectionFactory.HTTPServerSessionListener
- All Implemented Interfaces:
ServerSessionListener
,Session.Listener
,Stream.Listener
- Enclosing class:
HTTP2ServerConnectionFactory
-
Field Summary
Fields inherited from interface org.eclipse.jetty.http2.api.Stream.Listener
AUTO_DISCARD
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
onClose
(Session session, GoAwayFrame frame, Callback callback) Callback method invoked when a GOAWAY frame caused the session to be closed.void
onDataAvailable
(Stream stream) Callback method invoked if the application has expresseddemand
for DATA frames, and if there may be content available.void
Callback method invoked when a failure has been detected for this session.void
Callback method invoked when the stream failed.void
onHeaders
(Stream stream, HeadersFrame frame) Callback method invoked when a HEADERS frame representing the HTTP response has been received.boolean
onIdleTimeout
(Session session) Callback method invoked when the idle timeout expired.void
onIdleTimeout
(Stream stream, TimeoutException x, Promise<Boolean> promise) Callback method invoked when the stream exceeds its idle timeout.onNewStream
(Stream stream, HeadersFrame frame) Callback method invoked when a new stream is being created upon receiving a HEADERS frame representing an HTTP request.Callback method invoked:onPush
(Stream stream, PushPromiseFrame frame) Callback method invoked when a PUSH_PROMISE frame has been received.void
onReset
(Stream stream, ResetFrame frame, Callback callback) Callback method invoked when a RST_STREAM frame has been received for this stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.http2.api.server.ServerSessionListener
onAccept
Methods inherited from interface org.eclipse.jetty.http2.api.Session.Listener
onGoAway, onPing, onReset, onSettings
Methods inherited from interface org.eclipse.jetty.http2.api.Stream.Listener
onClosed, onNewStream
-
Constructor Details
-
HTTPServerSessionListener
-
-
Method Details
-
onPreface
Description copied from interface:Session.Listener
Callback method invoked:
- for clients, just before the preface is sent, to gather the SETTINGS configuration options the client wants to send to the server;
- for servers, just after having received the preface, to gather the SETTINGS configuration options the server wants to send to the client.
- Specified by:
onPreface
in interfaceSession.Listener
- Parameters:
session
- the session- Returns:
- a (possibly empty or null) map containing SETTINGS configuration options to send.
-
onNewStream
Description copied from interface:Session.Listener
Callback method invoked when a new stream is being created upon receiving a HEADERS frame representing an HTTP request.
Applications should implement this method to process HTTP requests, typically providing an HTTP response via
Stream.headers(HeadersFrame, Callback)
.Applications can detect whether request DATA frames will be arriving by testing
HeadersFrame.isEndStream()
. If the application is interested in processing the DATA frames, it must demand for DATA frames usingStream.demand()
and then return either aStream.Listener
implementation that overridesStream.Listener.onDataAvailable(Stream)
where applications can read from theStream
viaStream.readData()
, orStream.Listener.AUTO_DISCARD
that automatically reads and discards DATA frames. Returningnull
is possible but discouraged, and has the same effect of demanding and discarding the DATA frames.- Specified by:
onNewStream
in interfaceSession.Listener
- Parameters:
stream
- the newly created streamframe
- the HEADERS frame received- Returns:
- a
Stream.Listener
that will be notified of stream events
-
onIdleTimeout
Description copied from interface:Session.Listener
Callback method invoked when the idle timeout expired.
- Specified by:
onIdleTimeout
in interfaceSession.Listener
- Parameters:
session
- the session- Returns:
- whether the session should be closed
-
onClose
Description copied from interface:Session.Listener
Callback method invoked when a GOAWAY frame caused the session to be closed.
- Specified by:
onClose
in interfaceSession.Listener
- Parameters:
session
- the sessionframe
- the GOAWAY frame that caused the session to be closedcallback
- the callback to notify of the GOAWAY processing
-
onFailure
Description copied from interface:Session.Listener
Callback method invoked when a failure has been detected for this session.
- Specified by:
onFailure
in interfaceSession.Listener
- Parameters:
session
- the sessionfailure
- the failurecallback
- the callback to notify of failure processing
-
onHeaders
Description copied from interface:Stream.Listener
Callback method invoked when a HEADERS frame representing the HTTP response has been received.
- Specified by:
onHeaders
in interfaceStream.Listener
- Parameters:
stream
- the streamframe
- the HEADERS frame received
-
onPush
Description copied from interface:Stream.Listener
Callback method invoked when a PUSH_PROMISE frame has been received.
Applications that override this method are typically interested in processing the pushed stream DATA frames, and must demand for pushed DATA frames via
Stream.demand()
and then return either aStream.Listener
implementation that overridesStream.Listener.onDataAvailable(Stream)
where applications can read from theStream
viaStream.readData()
, orStream.Listener.AUTO_DISCARD
that automatically reads and discards DATA frames. Returningnull
is possible but discouraged, and has the same effect of demanding and discarding the pushed DATA frames.- Specified by:
onPush
in interfaceStream.Listener
- Parameters:
stream
- the pushed streamframe
- the PUSH_PROMISE frame received- Returns:
- a Stream.Listener that will be notified of pushed stream events
-
onDataAvailable
Description copied from interface:Stream.Listener
Callback method invoked if the application has expressed
demand
for DATA frames, and if there may be content available.Applications that wish to handle DATA frames should call
Stream.demand()
for this method to be invoked when the data is available.Server applications should typically demand from
Stream.Listener.onNewStream(Stream)
(upon receiving an HTTP request), while client applications should typically demand fromStream.Listener.onHeaders(Stream, HeadersFrame)
(upon receiving an HTTP response).Just prior calling this method, the outstanding demand is cancelled; applications that implement this method should read content calling
Stream.readData()
, and callStream.demand()
to signal to the implementation to call again this method when there may be more content available.Only one thread at a time invokes this method, although it may not be the same thread across different invocations.
It is always guaranteed that invoking
Stream.demand()
from within this method will not cause aStackOverflowError
.Typical usage:
class MyStreamListener implements Stream.Listener { @Override public void onDataAvailable(Stream stream) { // Read a chunk of the content. Stream.Data data = stream.readData(); if (data == null) { // No data available now, demand to be called back. stream.demand(); } else { // Process the content. process(data.frame().getByteBuffer()); // Notify that the content has been consumed. data.release(); if (!data.frame().isEndStream()) { // Demand to be called back. stream.demand(); } } } }
- Specified by:
onDataAvailable
in interfaceStream.Listener
- Parameters:
stream
- the stream- See Also:
-
onReset
Description copied from interface:Stream.Listener
Callback method invoked when a RST_STREAM frame has been received for this stream.
- Specified by:
onReset
in interfaceStream.Listener
- Parameters:
stream
- the streamframe
- the RST_STREAM frame receivedcallback
- the callback to complete when the reset has been handled
-
onFailure
public void onFailure(Stream stream, int error, String reason, Throwable failure, Callback callback) Description copied from interface:Stream.Listener
Callback method invoked when the stream failed.
- Specified by:
onFailure
in interfaceStream.Listener
- Parameters:
stream
- the streamerror
- the error codereason
- the error reason, or nullfailure
- the failurecallback
- the callback to complete when the failure has been handled
-
onIdleTimeout
Description copied from interface:Stream.Listener
Callback method invoked when the stream exceeds its idle timeout.
- Specified by:
onIdleTimeout
in interfaceStream.Listener
- Parameters:
stream
- the streamx
- the timeout failurepromise
- the promise to complete- See Also:
-