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

pack-priv abstract sealed Class Http3Stream<T>

extends ExchangeImpl<T>
permits Http3ExchangeImpl<T>, Http3PushPromiseStream<T>
Class Inheritance
Known Direct Subclasses
jdk.internal.net.http.Http3ExchangeImpl, jdk.internal.net.http.Http3PushPromiseStream
Type Parameters
<T>
the expected type of the response body
Imports
java.io.EOFException, .IOException, .UncheckedIOException, java.net.ProtocolException, java.net.http.HttpHeaders, java.nio.ByteBuffer, java.util.List, java.util.concurrent.ConcurrentLinkedQueue, java.util.concurrent.atomic.AtomicInteger, jdk.internal.net.http.common.HttpHeadersBuilder, .Log, .Logger, .SequentialScheduler, .Utils, .ValidatingHeadersConsumer, jdk.internal.net.http.http3.Http3Error, jdk.internal.net.http.http3.frames.DataFrame, .FramesDecoder, .HeadersFrame, .Http3Frame, .Http3FrameType, .MalformedFrame, .PartialFrame, .PushPromiseFrame, .UnknownFrame, jdk.internal.net.http.qpack.Decoder, .DecodingCallback, jdk.internal.net.http.qpack.readers.HeaderFrameReader, jdk.internal.net.http.quic.streams.QuicStreamReader

A common super class for the HTTP/3 request/response stream (Http3ExchangeImpl and the HTTP/3 push promises stream (Http3PushPromiseStream.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum
pack-priv abstract class
Http3Stream.StreamHeadersConsumer

A base class implementing DecodingCallback used for receiving and building HttpHeaders.

Field Summary

Modifier and TypeField and Description
private long
private Long
private final AtomicInteger
private volatile boolean
private volatile long
pack-priv final ConcurrentLinkedQueue<List<ByteBuffer>>
private Http3Stream.ResponseState
Inherited from jdk.internal.net.http.ExchangeImpl:
exchange

Constructor Summary

AccessConstructor and Description
pack-priv
Http3Stream(Exchange<T> exchange)

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract void
cancelImpl(Throwable
an exception to be relayed to the multi exchange through the completable future chain
throwable
,
Http3Error
an HTTP/3 error
error
)

Cancel the stream exchange on error

pack-priv final String
pack-priv abstract void
completeResponse(Response
the Response that was received.
response
)

Called at the end of handleResponse, to propagate the response to the multi exchange.

pack-priv void
connectionError(Throwable
an exception to be relayed to the multi exchange through the completable future chain
throwable
,
Http3Error
an HTTP/3 error
error
)

Notify of a connection error.

pack-priv abstract void
connectionError(Throwable
an exception to be relayed to the multi exchange through the completable future chain
throwable
,
long
an HTTP/3 error code
errorCode
,
String
an error message to be logged when closing the connection
errMsg
)

Notify of a connection error.

pack-priv void
handleResponse(HttpHeadersBuilder
the response headers builder
responseHeadersBuilder
,
Http3Stream<T>.StreamHeadersConsumer
the response headers consumer
rspHeadersConsumer
,
SequentialScheduler
the read scheduler
readScheduler
,
Logger
the debug logger
debug
)

Validate response headers and status code based on the responseState.

pack-priv abstract Response

Returns:

a new Response object
newResponse
(HttpHeaders
response headers
responseHeaders
,
int
response code
responseCode
)

Called to create a new Response object for the newly receive response headers and response status code.

pack-priv abstract void
onPollException(QuicStreamReader
the stream reader
reader
,
IOException
the exception caught
io
)

Called when an exception is thrown by reader::poll when called from processQuicData.

pack-priv abstract void
onReaderReset()

Called when processQuicData detects that the reader has been reset.

private ByteBuffer
pack-priv void
processQuicData(QuicStreamReader reader, FramesDecoder framesDecoder, H3FrameOrderVerifier frameOrderVerifier, SequentialScheduler readScheduler, Logger debug)

Invoked when some data is received from the underlying quic stream.

pack-priv abstract void
pushResponseData(ConcurrentLinkedQueue<List<ByteBuffer>>
a queue of available data to be pushed to the subscriber
responseData
)

Push response data to the response body subscriber if allowed by the subscription state.

pack-priv boolean

Returns:

whether reading from the quic stream is currently paused
readingPaused
()

Returns whether reading from the quic stream is currently paused.

private void
receiveData(DataFrame data, List<ByteBuffer> payload, Logger debug)

public long

Returns:

count of bytes read from the QUIC stream so far
receivedQuicBytes
()

Returns count of bytes read from the QUIC stream so far.

pack-priv abstract void
receiveHeaders(HeadersFrame
a partially received header frame
headers
,
List<ByteBuffer>
the payload bytes available for that frame
payload
)

Called when new payload data is received by processQuicData for a given header frame.

pack-priv abstract void
receivePushPromiseFrame(PushPromiseFrame
a partially received push promise frame
ppf
,
List<ByteBuffer>
the payload bytes available for that frame
payload
)

Called when new payload data is received by processQuicData for a given push promise frame.

pack-priv abstract long

Returns:

the Quic stream id for this exchange (request/response or push response)
streamId
()

Returns the Quic stream id for this exchange (request/response or push response).

pack-priv void
switchReadingPaused(boolean
the new value
value
)

Switches the value of the readingPaused flag

Subclasses of Http3Stream can call this method to switch the value of this flag if needed, typically in their concrete implementation of receiveHeaders(HeadersFrame, List).

private Throwable
toThrowable(MalformedFrame malformedFrame)

Inherited from jdk.internal.net.http.ExchangeImpl:
cancelcancelcancelTimerOnResponseBodySubscriberTerminationclientcompletedconnectioncreateResponseSubscriberexpectContinueFailedexpectTimeoutRaisedgetgetCancelCausegetExchangegetResponseAsyncignoreBodyisCancelednullBodyonProtocolErrorreadBodyAsyncreleasedsendBodyAsyncsendHeadersAsyncsetExpectTimeoutRaisedupgraded

Field Detail

consumedDataBytesback to summary
private long consumedDataBytes
contentLengthback to summary
private Long contentLength
nonFinalResponseCountback to summary
private final AtomicInteger nonFinalResponseCount
readingPausedback to summary
private volatile boolean readingPaused
receivedQuicBytesback to summary
private volatile long receivedQuicBytes
responseDataback to summary
pack-priv final ConcurrentLinkedQueue<List<ByteBuffer>> responseData
responseStateback to summary
private Http3Stream.ResponseState responseState

Constructor Detail

Http3Streamback to summary
pack-priv Http3Stream(Exchange<T> exchange)

Method Detail

cancelImplback to summary
pack-priv abstract void cancelImpl(Throwable throwable, Http3Error error)

Cancel the stream exchange on error

Parameters
throwable:Throwable

an exception to be relayed to the multi exchange through the completable future chain

error:Http3Error

an HTTP/3 error

checkInterimResponseCountExceededback to summary
pack-priv final String checkInterimResponseCountExceeded()
completeResponseback to summary
pack-priv abstract void completeResponse(Response response)

Called at the end of handleResponse, to propagate the response to the multi exchange.

Parameters
response:Response

the Response that was received.

connectionErrorback to summary
pack-priv void connectionError(Throwable throwable, Http3Error error)

Notify of a connection error. The implementation of this method is supposed to close all exchanges, cancel all push promises, and close the connection.

Implementation Specification

The implementation of this method calls

connectionError(throwable, error.code(), throwable.getMessage());
connectionError(throwable, error.code(), throwable.getMessage());
Parameters
throwable:Throwable

an exception to be relayed to the multi exchange through the completable future chain

error:Http3Error

an HTTP/3 error

connectionErrorback to summary
pack-priv abstract void connectionError(Throwable throwable, long errorCode, String errMsg)

Notify of a connection error. The implementation of this method is supposed to close all exchanges, cancel all push promises, and close the connection.

Parameters
throwable:Throwable

an exception to be relayed to the multi exchange through the completable future chain

errorCode:long

an HTTP/3 error code

errMsg:String

an error message to be logged when closing the connection

handleResponseback to summary
pack-priv void handleResponse(HttpHeadersBuilder responseHeadersBuilder, Http3Stream<T>.StreamHeadersConsumer rspHeadersConsumer, SequentialScheduler readScheduler, Logger debug)

Validate response headers and status code based on the responseState. If validated, this method will call newResponse(HttpHeaders, int) to create a Response object, which it will then pass to completeResponse(Response).

Parameters
responseHeadersBuilder:HttpHeadersBuilder

the response headers builder

rspHeadersConsumer:Http3Stream<T>.StreamHeadersConsumer

the response headers consumer

readScheduler:SequentialScheduler

the read scheduler

debug:Logger

the debug logger

newResponseback to summary
pack-priv abstract Response newResponse(HttpHeaders responseHeaders, int responseCode)

Called to create a new Response object for the newly receive response headers and response status code. This method is called from handleResponse, after the status code and headers have been validated.

Parameters
responseHeaders:HttpHeaders

response headers

responseCode:int

response code

Returns:Response

a new Response object

onPollExceptionback to summary
pack-priv abstract void onPollException(QuicStreamReader reader, IOException io)

Called when an exception is thrown by reader::poll when called from processQuicData. This is typically only used for logging purposes.

Parameters
reader:QuicStreamReader

the stream reader

io:IOException

the exception caught

onReaderResetback to summary
pack-priv abstract void onReaderReset()

Called when processQuicData detects that the reader has been reset. This method should do the appropriate garbage collection, possibly closing the exchange or the connection if needed, and closing the read scheduler.

pollIfNotResetback to summary
private ByteBuffer pollIfNotReset(QuicStreamReader reader) throws IOException
processQuicDataback to summary
pack-priv void processQuicData(QuicStreamReader reader, FramesDecoder framesDecoder, H3FrameOrderVerifier frameOrderVerifier, SequentialScheduler readScheduler, Logger debug) throws IOException

Invoked when some data is received from the underlying quic stream. This implements the read loop for a request-response stream or a push response stream.

pushResponseDataback to summary
pack-priv abstract void pushResponseData(ConcurrentLinkedQueue<List<ByteBuffer>> responseData)

Push response data to the response body subscriber if allowed by the subscription state.

Parameters
responseData:ConcurrentLinkedQueue<List<ByteBuffer>>

a queue of available data to be pushed to the subscriber

readingPausedback to summary
pack-priv boolean readingPaused()

Returns whether reading from the quic stream is currently paused. Typically reading is paused when waiting for headers to be decoded by QPack.

Returns:boolean

whether reading from the quic stream is currently paused

receiveDataback to summary
private void receiveData(DataFrame data, List<ByteBuffer> payload, Logger debug)
receivedQuicBytesback to summary
public long receivedQuicBytes()

Returns count of bytes read from the QUIC stream so far.

Returns:long

count of bytes read from the QUIC stream so far

receiveHeadersback to summary
pack-priv abstract void receiveHeaders(HeadersFrame headers, List<ByteBuffer> payload) throws IOException

Called when new payload data is received by processQuicData for a given header frame.

Any exception thrown here will be rethrown by processQuicData

Parameters
headers:HeadersFrame

a partially received header frame

payload:List<ByteBuffer>

the payload bytes available for that frame

Exceptions
IOException:
if an error is detected
receivePushPromiseFrameback to summary
pack-priv abstract void receivePushPromiseFrame(PushPromiseFrame ppf, List<ByteBuffer> payload) throws IOException

Called when new payload data is received by processQuicData for a given push promise frame.

Any exception thrown here will be rethrown by processQuicData

Parameters
ppf:PushPromiseFrame

a partially received push promise frame

payload:List<ByteBuffer>

the payload bytes available for that frame

Exceptions
IOException:
if an error is detected
streamIdback to summary
pack-priv abstract long streamId()

Returns the Quic stream id for this exchange (request/response or push response).

Returns:long

the Quic stream id for this exchange (request/response or push response)

switchReadingPausedback to summary
pack-priv void switchReadingPaused(boolean value)

Switches the value of the readingPaused flag

Subclasses of Http3Stream can call this method to switch the value of this flag if needed, typically in their concrete implementation of receiveHeaders(HeadersFrame, List).

Parameters
value:boolean

the new value

toThrowableback to summary
private Throwable toThrowable(MalformedFrame malformedFrame)
jdk.internal.net.http back to summary

pack-priv final Enum Http3Stream.ResponseState

extends Enum<Http3Stream.ResponseState>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Http3Stream.ResponseState
public static final Http3Stream.ResponseState
public static final Http3Stream.ResponseState

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Http3Stream.ResponseState
public static Http3Stream.ResponseState[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

PERMIT_HEADERback to summary
public static final Http3Stream.ResponseState PERMIT_HEADER
PERMIT_NONEback to summary
public static final Http3Stream.ResponseState PERMIT_NONE
PERMIT_TRAILERback to summary
public static final Http3Stream.ResponseState PERMIT_TRAILER

Constructor Detail

ResponseStateback to summary
private ResponseState()

Method Detail

valueOfback to summary
public static Http3Stream.ResponseState valueOf(String name)
valuesback to summary
public static Http3Stream.ResponseState[] values()
jdk.internal.net.http back to summary

pack-priv abstract Class Http3Stream.StreamHeadersConsumer

extends ValidatingHeadersConsumer
implements DecodingCallback
Class Inheritance
All Implemented Interfaces
jdk.internal.net.http.qpack.DecodingCallback
Known Direct Subclasses
jdk.internal.net.http.Http3ExchangeImpl.HeadersConsumer, jdk.internal.net.http.Http3PushPromiseStream.PushRespHeadersConsumer

A base class implementing DecodingCallback used for receiving and building HttpHeaders. Can be used for request headers, response headers, push response headers, or trailers.

Field Summary

Modifier and TypeField and Description
private volatile boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
hasError()

Overrides default jdk.internal.net.http.qpack.DecodingCallback.hasError.

Reports if a connection or a stream error has been observed during the decoding process

pack-priv String
pack-priv abstract HeaderFrameReader
pack-priv abstract HttpHeadersBuilder
pack-priv abstract void
public void
onComplete()

Implements jdk.internal.net.http.qpack.DecodingCallback.onComplete.

A header fields decoding is completed.

public void
onConnectionError(Throwable throwable, Http3Error http3Error)

Implements jdk.internal.net.http.qpack.DecodingCallback.onConnectionError.

A connection-level error observed during the decoding process.

public void
onDecoded(CharSequence name, CharSequence value)

Overrides jdk.internal.net.http.common.ValidatingHeadersConsumer.onDecoded.

Implements jdk.internal.net.http.qpack.DecodingCallback.onDecoded.

A method the more specific methods of the callback forward their calls to.

public void
onStreamError(Throwable throwable, Http3Error http3Error)

Overrides default jdk.internal.net.http.qpack.DecodingCallback.onStreamError.

A stream-level error observed during the decoding process.

pack-priv abstract Decoder
public void
reset()

Overrides jdk.internal.net.http.common.ValidatingHeadersConsumer.reset.

Called when END_HEADERS was received.

pack-priv abstract void
Inherited from jdk.internal.net.http.common.ValidatingHeadersConsumer:
formatMessagenewException

Field Detail

hasErrorback to summary
private volatile boolean hasError

Constructor Detail

StreamHeadersConsumerback to summary
pack-priv StreamHeadersConsumer(ValidatingHeadersConsumer.Context context)

Method Detail

hasErrorback to summary
public boolean hasError()

Overrides default jdk.internal.net.http.qpack.DecodingCallback.hasError.

Doc from jdk.internal.net.http.qpack.DecodingCallback.hasError.

Reports if a connection or a stream error has been observed during the decoding process

Annotations
@Override
headerFieldTypeback to summary
pack-priv String headerFieldType()
headerFrameReaderback to summary
pack-priv abstract HeaderFrameReader headerFrameReader()
headersBuilderback to summary
pack-priv abstract HttpHeadersBuilder headersBuilder()
headersCompletedback to summary
pack-priv abstract void headersCompleted()
onCompleteback to summary
public void onComplete()

Implements jdk.internal.net.http.qpack.DecodingCallback.onComplete.

Doc from jdk.internal.net.http.qpack.DecodingCallback.onComplete.

A header fields decoding is completed.

Annotations
@Override
onConnectionErrorback to summary
public void onConnectionError(Throwable throwable, Http3Error http3Error)

Implements jdk.internal.net.http.qpack.DecodingCallback.onConnectionError.

Doc from jdk.internal.net.http.qpack.DecodingCallback.onConnectionError.

A connection-level error observed during the decoding process.

Annotations
@Override
onDecodedback to summary
public void onDecoded(CharSequence name, CharSequence value)

Overrides jdk.internal.net.http.common.ValidatingHeadersConsumer.onDecoded.

Implements jdk.internal.net.http.qpack.DecodingCallback.onDecoded.

Doc from jdk.internal.net.http.qpack.DecodingCallback.onDecoded.

A method the more specific methods of the callback forward their calls to.

Annotations
@Override
onStreamErrorback to summary
public void onStreamError(Throwable throwable, Http3Error http3Error)

Overrides default jdk.internal.net.http.qpack.DecodingCallback.onStreamError.

Doc from jdk.internal.net.http.qpack.DecodingCallback.onStreamError.

A stream-level error observed during the decoding process.

Annotations
@Override
qpackDecoderback to summary
pack-priv abstract Decoder qpackDecoder()
resetback to summary
public void reset()

Overrides jdk.internal.net.http.common.ValidatingHeadersConsumer.reset.

Doc from jdk.internal.net.http.common.ValidatingHeadersConsumer.reset.

Called when END_HEADERS was received. This consumer may be invoked again after reset() is called, but for a whole new set of headers.

Annotations
@Override
resetDoneback to summary
pack-priv abstract void resetDone()