Top Description Inners Methods
org.eclipse.jetty.http3.api

public Interface Session

Known Direct Subinterfaces
org.eclipse.jetty.http3.api.Session.Client, org.eclipse.jetty.http3.api.Session.Server
Known Direct Implementers
org.eclipse.jetty.http3.HTTP3Session
Imports
java.net.SocketAddress, java.util.Collection, .Collections, .Map, java.util.concurrent.CompletableFuture, org.eclipse.jetty.http3.frames.GoAwayFrame, .HeadersFrame, .SettingsFrame

The low-level HTTP/3 API representing a connection with a remote peer.

A Session is the active part of the connection, and by calling its APIs applications can generate events on the connection.

Conversely, Session.Listener is the passive part of the connection, and has callback methods that are invoked when events happen on the connection.

See Also
Client, Server, Listener

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Session.Client

The client-side HTTP/3 API representing a connection with a server.

public static interface
Session.Listener

A Listener is the passive counterpart of a Session and receives events happening on an HTTP/3 connection.

public static interface
Session.Server

The server-side HTTP/3 API representing a connection with a client.

Method Summary

Modifier and TypeMethod and Description
public default SocketAddress

Returns:

the local socket address this session is bound to
getLocalSocketAddress
()

Get the local socket address this session is bound to.

public default SocketAddress

Returns:

the remote socket address this session is connected to
getRemoteSocketAddress
()

Get the remote socket address this session is connected to.

public default Collection<Stream>
getStreams()

Returns: a snapshot of all the streams currently belonging to this session

public default CompletableFuture<Void>

Returns:

the CompletableFuture that gets notified when the frame has been sent
goAway
(boolean
whether the shutdown should be graceful
graceful
)

Initiates the shutdown of this session by sending a GOAWAY frame to the other peer.

Method Detail

getLocalSocketAddressback to summary
public default SocketAddress getLocalSocketAddress()

Get the local socket address this session is bound to.

Returns:SocketAddress

the local socket address this session is bound to

getRemoteSocketAddressback to summary
public default SocketAddress getRemoteSocketAddress()

Get the remote socket address this session is connected to.

Returns:SocketAddress

the remote socket address this session is connected to

getStreamsback to summary
public default Collection<Stream> getStreams()
Returns:Collection<Stream>

a snapshot of all the streams currently belonging to this session

goAwayback to summary
public default CompletableFuture<Void> goAway(boolean graceful)

Initiates the shutdown of this session by sending a GOAWAY frame to the other peer.

Parameters
graceful:boolean

whether the shutdown should be graceful

Returns:CompletableFuture<Void>

the CompletableFuture that gets notified when the frame has been sent

org.eclipse.jetty.http3.api back to summary

public Interface Session.Client

extends Session

The client-side HTTP/3 API representing a connection with a server.

Once a Session has been obtained, it can be used to make HTTP/3 requests:

Session session = ...;
HeadersFrame headersFrame = ...;
session.newRequest(headersFrame, new Stream.Listener()
{
    @Override
    public void onResponse(Stream stream, HeadersFrame frame)
    {
        // Response headers received.
    }
});
See Also
Stream

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Session.Client.Listener

The client-side specific Session.Listener.

Method Summary

Modifier and TypeMethod and Description
public CompletableFuture<Stream>

Returns:

a CompletableFuture that is notified of the stream creation
newRequest
(HeadersFrame
the HEADERS frame containing the HTTP request headers
frame
,
Stream.Client.Listener
the listener that gets notified of stream events
listener
)

Makes a request by creating a HTTP/3 stream and sending the given HEADERS frame.

Inherited from org.eclipse.jetty.http3.api.Session:
getLocalSocketAddressgetRemoteSocketAddressgetStreamsgoAway

Method Detail

newRequestback to summary
public CompletableFuture<Stream> newRequest(HeadersFrame frame, Stream.Client.Listener listener)

Makes a request by creating a HTTP/3 stream and sending the given HEADERS frame.

Parameters
frame:HeadersFrame

the HEADERS frame containing the HTTP request headers

listener:Stream.Client.Listener

the listener that gets notified of stream events

Returns:CompletableFuture<Stream>

a CompletableFuture that is notified of the stream creation

org.eclipse.jetty.http3.api back to summary

public Interface Session.Client.Listener

extends Listener

The client-side specific Session.Listener.

org.eclipse.jetty.http3.api back to summary

public Interface Session.Listener

Known Direct Subinterfaces
org.eclipse.jetty.http3.api.Session.Client.Listener, org.eclipse.jetty.http3.api.Session.Server.Listener

A Listener is the passive counterpart of a Session and receives events happening on an HTTP/3 connection.

See Also
Session

Method Summary

Modifier and TypeMethod and Description
public default void
onDisconnect(Session
the session
session
,
long
the disconnect error
error
,
String
the disconnect reason
reason
)

Callback method invoked when the underlying transport has been disconnected.

public default void
onFailure(Session
the session
session
,
long
the failure error
error
,
String
the failure reason
reason
,
Throwable
the failure
failure
)

Callback method invoked when a failure has been detected for this session.

public default void
onGoAway(Session
the session
session
,
GoAwayFrame
the GOAWAY frame received
frame
)

Callback method invoked when a GOAWAY frame has been received.

public default boolean

Returns:

true to confirm the idle timeout, false to ignore the idle timeout
onIdleTimeout
(Session
the session
session
)

Callback method invoked when the idle timeout has expired.

public default Map<Long, Long>

Returns:

a (possibly empty or null) map containing configuration settings to send to the remote peer.
onPreface
(Session
the session
session
)

Callback method invoked just before the initial SETTINGS frame is sent to the remote peer, to gather the configuration settings that the local peer wants to send to the remote peer.

public default void
onSettings(Session
the session
session
,
SettingsFrame
the SETTINGS frame received
frame
)

Callback method invoked when a SETTINGS frame has been received.

Method Detail

onDisconnectback to summary
public default void onDisconnect(Session session, long error, String reason)

Callback method invoked when the underlying transport has been disconnected.

Parameters
session:Session

the session

error:long

the disconnect error

reason:String

the disconnect reason

onFailureback to summary
public default void onFailure(Session session, long error, String reason, Throwable failure)

Callback method invoked when a failure has been detected for this session.

Parameters
session:Session

the session

error:long

the failure error

reason:String

the failure reason

failure:Throwable

the failure

onGoAwayback to summary
public default void onGoAway(Session session, GoAwayFrame frame)

Callback method invoked when a GOAWAY frame has been received.

Parameters
session:Session

the session

frame:GoAwayFrame

the GOAWAY frame received

onIdleTimeoutback to summary
public default boolean onIdleTimeout(Session session)

Callback method invoked when the idle timeout has expired.

Parameters
session:Session

the session

Returns:boolean

true to confirm the idle timeout, false to ignore the idle timeout

onPrefaceback to summary
public default Map<Long, Long> onPreface(Session session)

Callback method invoked just before the initial SETTINGS frame is sent to the remote peer, to gather the configuration settings that the local peer wants to send to the remote peer.

Parameters
session:Session

the session

Returns:Map<Long, Long>

a (possibly empty or null) map containing configuration settings to send to the remote peer.

onSettingsback to summary
public default void onSettings(Session session, SettingsFrame frame)

Callback method invoked when a SETTINGS frame has been received.

Parameters
session:Session

the session

frame:SettingsFrame

the SETTINGS frame received

org.eclipse.jetty.http3.api back to summary

public Interface Session.Server

extends Session

The server-side HTTP/3 API representing a connection with a client.

To receive HTTP/3 request events, see Session.Server.Listener#onRequest(Stream.Server, HeadersFrame).

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Session.Server.Listener

The server-side specific Session.Listener.

Method Summary

Inherited from org.eclipse.jetty.http3.api.Session:
getLocalSocketAddressgetRemoteSocketAddressgetStreamsgoAway
org.eclipse.jetty.http3.api back to summary

public Interface Session.Server.Listener

extends Listener

The server-side specific Session.Listener.

Method Summary

Modifier and TypeMethod and Description
public default void
onAccept(Session
the session
session
)

Callback method invoked when a connection has been accepted by the server.

public default Stream.Server.Listener

Returns:

a Stream.Server.Listener that will be notified of stream events
onRequest
(Stream.Server
the stream associated with the request
stream
,
HeadersFrame
the HEADERS frame containing the request headers
frame
)

Callback method invoked when a request is received.

Inherited from org.eclipse.jetty.http3.api.Session.Listener:
onDisconnectonFailureonGoAwayonIdleTimeoutonPrefaceonSettings

Method Detail

onAcceptback to summary
public default void onAccept(Session session)

Callback method invoked when a connection has been accepted by the server.

Parameters
session:Session

the session

onRequestback to summary
public default Stream.Server.Listener onRequest(Stream.Server stream, HeadersFrame frame)

Callback method invoked when a request is received.

Applications should implement this method to process HTTP/3 requests, typically providing an HTTP/3 response via Stream.Server#respond(HeadersFrame):

class MyServer implements Session.Server.Listener
{
    @Override
    public Stream.Server.Listener onRequest(Stream.Server stream, HeadersFrame frame)
    {
        // Send a response.
        var response = new MetaData.Response(HttpVersion.HTTP_3, HttpStatus.OK_200, HttpFields.EMPTY);
        stream.respond(new HeadersFrame(response, true));
        if (!frame.isLast())
            stream.demand();
        return null;
    }
}

If there is request content (indicated by the fact that the HEADERS frame is not the last in the stream), then applications either:

Parameters
stream:Stream.Server

the stream associated with the request

frame:HeadersFrame

the HEADERS frame containing the request headers

Returns:Stream.Server.Listener

a Stream.Server.Listener that will be notified of stream events

See Also
Stream.Server.Listener#onDataAvailable(Stream.Server)