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. is the passive part of the connection,
and has callback methods that are invoked when events happen on the connection.
Client, Server, Listener
| Modifier and Type | Class and Description |
|---|---|
| public static interface | Session.
The client-side HTTP/3 API representing a connection with a server. |
| public static interface | Session.
A |
| public static interface | Session.
The server-side HTTP/3 API representing a connection with a client. |
| Modifier and Type | Method and Description |
|---|---|
| public default SocketAddress | Returns: the local socket address this session is bound toGet the local socket address this session is bound to. |
| public default SocketAddress | Returns: the remote socket address this session is connected toGet the remote socket address this session is connected to. |
| public default Collection | |
| public default CompletableFuture | Returns: theCompletableFuture that gets notified when the frame has been sentwhether the shutdown should be graceful graceful)Initiates the shutdown of this session by sending a GOAWAY frame to the other peer. |
| getLocalSocketAddress | back to summary |
|---|---|
| public default SocketAddress getLocalSocketAddress() Get the local socket address this session is bound to.
| |
| getRemoteSocketAddress | back to summary |
|---|---|
| public default SocketAddress getRemoteSocketAddress() Get the remote socket address this session is connected to.
| |
| getStreams | back to summary |
|---|---|
public default Collection
| |
| goAway | back to summary |
|---|---|
| public default CompletableFuture Initiates the shutdown of this session by sending a GOAWAY frame to the other peer.
| |
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.
}
});
Stream
| Modifier and Type | Class and Description |
|---|---|
| public static interface | Session.
The client-side specific |
| Modifier and Type | Method and Description |
|---|---|
| public CompletableFuture | Returns: a CompletableFuture that is notified of the stream creationthe HEADERS frame containing the HTTP request headers frame, Stream.the listener that gets notified of stream events listenerMakes a request by creating a HTTP/3 stream and sending the given HEADERS frame. |
| newRequest | back to summary |
|---|---|
| public CompletableFuture Makes a request by creating a HTTP/3 stream and sending the given HEADERS frame.
| |
The client-side specific Session..
A Listener is the passive counterpart of a Session and
receives events happening on an HTTP/3 connection.
Session
| Modifier and Type | Method 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 | |
| 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 timeoutthe session session)Callback method invoked when the idle timeout has expired. |
| public default Map | Returns: a (possibly empty or null) map containing configuration settings to send to the remote peer.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. |
| onDisconnect | back to summary |
|---|---|
| public default void onDisconnect(Session session, long error, String reason) Callback method invoked when the underlying transport has been disconnected. | |
| onFailure | back 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. | |
| onGoAway | back to summary |
|---|---|
| public default void onGoAway(Session session, GoAwayFrame frame) Callback method invoked when a GOAWAY frame has been received.
| |
| onIdleTimeout | back to summary |
|---|---|
| public default boolean onIdleTimeout(Session session) Callback method invoked when the idle timeout has expired.
| |
| onPreface | back to summary |
|---|---|
| public default Map 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. | |
| onSettings | back to summary |
|---|---|
| public default void onSettings(Session session, SettingsFrame frame) Callback method invoked when a SETTINGS frame has been received.
| |
The server-side HTTP/3 API representing a connection with a client.
To receive HTTP/3 request events, see Session..
| Modifier and Type | Class and Description |
|---|---|
| public static interface | Session.
The server-side specific |
The server-side specific Session..
| Modifier and Type | Method and Description |
|---|---|
| public default void | |
| public default Stream. | Returns: aStream. that will be notified of stream eventsthe stream associated with the request stream,the HEADERS frame containing the request headers frame)Callback method invoked when a request is received. |
| onAccept | back to summary |
|---|---|
| public default void onAccept(Session session) Callback method invoked when a connection has been accepted by the server.
| |
| onRequest | back to summary |
|---|---|
| public default Stream. 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
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:
| |