APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.net.http

public final Class Http3Connection

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Imports
java.io.IOException, java.lang.invoke.MethodHandles, .VarHandle, java.net.ProtocolException, java.net.http.HttpHeaders, .HttpResponse.PushPromiseHandler.PushId, .HttpResponse.PushPromiseHandler.PushId.Http3PushId, .StreamLimitException, .UnsupportedProtocolVersionException, java.nio.ByteBuffer, java.nio.channels.ClosedChannelException, java.time.Duration, java.util.Optional, java.util.concurrent.CompletableFuture, .CompletionException, .ConcurrentHashMap, .ConcurrentMap, .ExecutionException, java.util.concurrent.atomic.AtomicLong, java.util.concurrent.locks.ReentrantLock, java.util.function.Consumer, .Function, .Predicate, jdk.internal.net.http.Http3PushManager.CancelPushReason, jdk.internal.net.http.common.Log, .Logger, .MinimalFuture, .Utils, jdk.internal.net.http.http3.ConnectionSettings, .Http3Error, jdk.internal.net.http.http3.frames.CancelPushFrame, .FramesDecoder, .GoAwayFrame, .Http3Frame, .Http3FrameType, .MalformedFrame, .MaxPushIdFrame, .PartialFrame, .SettingsFrame, jdk.internal.net.http.http3.streams.Http3Streams, .Http3Streams.StreamType, .PeerUniStreamDispatcher, .QueuingStreamPair, .UniStreamPair, jdk.internal.net.http.qpack.Decoder, .Encoder, .QPACK, .TableEntry, jdk.internal.net.http.quic.QuicConnection, .QuicStreamLimitException, .TerminationCause, .VariableLengthEncoder, jdk.internal.net.http.quic.streams.QuicBidiStream, .QuicReceiverStream, .QuicStream, .QuicStreamWriter, .QuicStreams

An HTTP/3 connection wraps an HttpQuicConnection and implements HTTP/3 on top it.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
Http3Connection.Http3StreamDispatcher

A class used to dispatch peer initiated unidirectional streams according to their HTTP/3 stream type.

pack-priv class

Field Summary

Modifier and TypeField and Description
private volatile boolean
private final Http3ClientImpl
private static final int
private static final VarHandle
pack-priv volatile int
private final HttpQuicConnection
private final String
private final FramesDecoder
private final UniStreamPair
private final String
private final Logger
private final ConcurrentMap<Long, Http3ExchangeImpl<?>>
private final ConcurrentMap<Long, QuicBidiStream>
private volatile boolean
private final H3FrameOrderVerifier
private static final int
private static final int
private volatile Http3Connection.IdleConnectionTimeoutEvent
private final Duration
private final AtomicLong
private final ReentrantLock
private final AtomicLong
private final AtomicLong
private volatile ConnectionSettings
private volatile ConnectionSettings
private final MinimalFuture<ConnectionSettings>
private volatile boolean
private final Http3PushManager
private final Decoder
private final UniStreamPair
private final Encoder
private final UniStreamPair
private final QuicConnection
private final Predicate<? super QuicReceiverStream>
private final AtomicLong
private volatile boolean
private volatile boolean

Constructor Summary

AccessConstructor and Description
pack-priv
Http3Connection(HttpRequestImpl
the request which triggered the creation of the connection
request
,
Http3ClientImpl
the Http3Client instance this connection belongs to
client
,
HttpQuicConnection
the HttpQuicConnection that was established
connection
)

Creates a new HTTP/3 connection over a given HttpQuicConnection.

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean

Returns:

true if the pushId can be processed
acceptLargerPushPromise
(QuicReceiverStream
a push stream (may be null if not yet materialized)
pushStream
,
long
a pushId, must be > 0
pushId
)

This method is called by the Http3PushManager to figure out whether a push stream or a push promise should be processed, with respect to the GOAWAY state.

pack-priv boolean
pack-priv void
private void
cancelIdleShutdownEvent()

Cancels any event that might have been scheduled to shutdown this connection.

private IOException
pack-priv IOException

Returns:

an IOException that can be used to complete a completable future if the maximum pushId is exceeded, null otherwise
checkMaxPushId
(long
the pushId
pushId
)

Checks whether the given pushId exceed the maximum pushId allowed to the peer, and if so, closes the connection.

private IOException

Returns:

an IOException that can be used to complete a completable future if the maximum pushId is exceeded, null otherwise
checkMaxPushId
(long
the pushId
pushId
,
long max)

Checks whether the given pushId exceed the maximum pushId allowed to the peer, and if so, closes the connection.

pack-priv void
checkSendMaxPushId()

Checks whether a MAX_PUSH_ID frame should be sent.

private static CompletableFuture<Void>
public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

pack-priv void
close(final Throwable throwable)

pack-priv void
close(final Http3Error error, final String message)

pack-priv void
close(final Http3Error error, final String logMsg, final Throwable closeCause)

pack-priv HttpQuicConnection
pack-priv void
pack-priv void
connectionError(Http3Stream<?> exchange, Throwable throwable, long errorCode, String logMsg)

pack-priv void
controlStreamFailed(final QuicStream stream, final UniStreamPair uniStreamPair, final Throwable throwable)

pack-priv static CompletableFuture<Http3Connection>

Returns:

a completable future that will be completed with a new HTTP/3 connection, or null if no usable HTTP/3 endpoint was found, or completed exceptionally if an error occurred
createAsync
(HttpRequestImpl
the first request that will go over this connection
request
,
Http3ClientImpl
the HTTP/3 client
h3client
,
Exchange<?>
the exchange for which this connection is created
exchange
)

Asynchronously create an instance of an HTTP/3 connection, if the server has a known HTTP/3 endpoint.

pack-priv QueuingStreamPair
pack-priv QueuingStreamPair
private <T> Http3ExchangeImpl<T>
pack-priv <U> CompletableFuture<? extends ExchangeImpl<U>>
createStream(final Exchange<U> exchange)

pack-priv String

Returns:

a debug tag
dbgTag
()

Debug tag used to create the debug logger for this HTTP/3 connection instance.

pack-priv void
decrementStreamsCount(Http3ExchangeImpl<?> exch, long streamid)

pack-priv String
private void
protected void
dispatchingFailed(QuicReceiverStream uni, Throwable
the reason of the failure
reason
)

Called if the dispatch failed.

private <T> T
private <T> T
private boolean
public long

Returns:

the minimum pushId that can be accepted from the peer
getMinPushId
()

Returns the minimum pushId that can be accepted from the peer.

pack-priv Optional<ConnectionSettings>

Returns:

the settings, sent by the peer, for this connection. If none is present, due to the SETTINGS frame not yet arriving from the peer, this method returns Optional#empty()
getPeerSettings
()

Returns the settings, sent by the peer, for this connection.

private void
handleIncomingGoAway(final GoAwayFrame incomingGoAway)

private void
handlePeerUnprocessedStreams(final long leastUnprocessedStreamId)

pack-priv boolean

Returns:

true if the final stream has been set.
isFinalStream
()

Whether the final stream (last stream allowed on a connection), has been set.

private boolean
isMarked(int state, int mask)

pack-priv boolean
private boolean
isQUICTrafficGenerationRequired()

This callback method is invoked by the QUIC layer when it notices that this connection hasn't seen any traffic for certain period of time.

pack-priv String
key()

pack-priv void
private void
lock()

private boolean
private boolean
markClosedState(int flag)

private boolean
private boolean
pack-priv HttpResponse.PushPromiseHandler.PushId

Returns:

a new PushId for the given pushId
newPushId
(long
the pushId
pushId
)

Returns a new PushId for the given pushId.

pack-priv void
noPushHandlerFor(long
the pushId
pushId
)

Called if a PushPromiseFrame is received by an exchange that doesn't have any java.net.http.HttpResponse.PushPromiseHandler.

private void
onDecoderStreamsFailed(final QuicStream stream, final UniStreamPair uniStreamPair, final Throwable throwable)

private void
onEncoderStreamsFailed(final QuicStream stream, final UniStreamPair uniStreamPair, final Throwable throwable)

pack-priv void
onExchangeClose(Http3ExchangeImpl<?> exch, final long
The request stream id
streamId
)

Called by the Http3ExchangeImpl when the exchange is closed.

private boolean

Returns:

always returns true (see QuicConnection#addRemoteStreamListener(Predicate)
onOpenRemoteStream
(QuicReceiverStream
the new stream
stream
)

This method is called when the peer opens a new stream.

pack-priv boolean

Returns:

true if the exchange should take care of creating the HttpResponse body, false otherwise
onPushPromiseFrame
(Http3ExchangeImpl<?>
The HTTP/3 exchange that received the frame
exchange
,
long
The pushId contained in the frame
pushId
,
HttpHeaders
The push promise headers contained in the frame
promiseHeaders
)

Called when a PushPromiseFrame has been decoded.

pack-priv void
onPushPromiseStream(QuicReceiverStream
the new push promise stream
pushStream
,
long
the pushId
pushId
)

Called when a new push promise stream is created by the peer, and the pushId has been read.

pack-priv <T> void
onPushPromiseStreamClosed(Http3PushPromiseStream<T> http3PushPromiseStream, long streamId)

pack-priv <T> void
onPushPromiseStreamStarted(Http3PushPromiseStream<T> http3PushPromiseStream, long streamId)

private void
onPushStreamCreated(QuicReceiverStream
the new push promise stream
pushStream
,
long
or -1 if the pushId is not available yet
pushId
)

Called when a new push promise stream is created by the peer.

protected boolean
onRemoteBidirectionalStream(QuicBidiStream
the new bidirectional stream opened by the peer.
bidi
)

Called when the peer opens a bidirectional stream.

protected boolean
onRemoteUnidirectionalStream(QuicReceiverStream
the unidirectional stream opened by the peer
uni
)

This method is called when the peer opens a unidirectional stream.

pack-priv CompletableFuture<ConnectionSettings>
private void
processPeerControlBytes(final ByteBuffer
the bytes received
buffer
)

This method is called to process bytes received on the peer control stream.

pack-priv void
pack-priv void
pushCancelled(long
the pushId to cancel
pushId
,
Throwable
the cause (may be null).
cause
)

Called when a pushId needs to be cancelled.

pack-priv Decoder
pack-priv Encoder
public String
private <T> Http3ExchangeImpl<T>
private boolean
pack-priv void
sendCancelPush(long
the pushId to cancel
pushId
,
Throwable
the reason for cancelling, may be null
cause
)

Sends a CANCEL_PUSH frame for the given pushId.

private void
private QuicStreamWriter

Returns:

the QuicStreamWriter passed as parameter
sendMaxPushId
(QuicStreamWriter
the control stream writer
writer
)

Schedules sending of max push id that this (client) connection allows.

private QuicStreamWriter

Returns:

a completable future that will be completed with the QuicStreamWriter allowing to write to the local control stream
sendMaxPushId
(QuicStreamWriter writer, long maxPushId)

Schedules sending of max push id that this (client) connection allows.

pack-priv void
sendMaxPushId(long
the new maxPushId
maxPushId
)

Send a MAX_PUSH_ID frame on the control stream with the given maxPushId

pack-priv QuicStreamWriter

Returns:

a completable future that will be completed with the QuicStreamWriter allowing to write to the local control stream
sendSettings
(QuicStreamWriter writer)

Schedules sending of client settings.

pack-priv void
setFinalStream()

Sets the final stream to be the next stream opened on the connection.

pack-priv void
pack-priv void
setPooled(final boolean present)

Mark this connection as being present or absent from the connection pool.

private static boolean
private void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

pack-priv boolean

Returns:

true if the connection has been successfully reserved and is isOpen(). false otherwise; in which case the connection must not be handed out from the pool.
tryReserveForPoolCheckout
()

Attempts to notify the idle connection management that this connection should be considered "in use".

private void
pack-priv CompletableFuture<Boolean>

Returns:

a completable future that will be completed when a pushId has been accepted by the exchange in charge of creating the response body
whenPushAccepted
(long
the pushId
pushId
)

Returns a completable future that will be completed when a pushId has been accepted by the exchange in charge of creating the response body.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait