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

public Class Encoder

extends Object
Class Inheritance
Imports
jdk.internal.net.http.http3.ConnectionSettings, jdk.internal.net.http.http3.streams.QueuingStreamPair, jdk.internal.net.http.qpack.QPACK.Logger, .QPACK.QPACKErrorHandler, .QPACK.StreamPairSupplier, .TableEntry.EntryType, jdk.internal.net.http.qpack.readers.DecoderInstructionsReader, jdk.internal.net.http.qpack.writers.EncoderInstructionsWriter, .FieldLineSectionPrefixWriter, .HeaderFrameWriter, jdk.internal.net.http.quic.streams.QuicStreamReader, java.net.ProtocolException, java.net.http.HttpHeaders, java.nio.ByteBuffer, java.util.ArrayList, .List, .Locale, .Map, .Queue, .Set, java.util.concurrent.ConcurrentHashMap, .ConcurrentLinkedQueue, .ConcurrentMap, .ConcurrentSkipListSet, java.util.concurrent.atomic.AtomicLong, java.util.concurrent.locks.ReentrantLock, .ReentrantReadWriteLock, java.util.function.Predicate

Encodes headers to their binary representation.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
public static record
Encoder.SectionReference

Descriptor of entries range referenced from a field lines section.

private class

Field Summary

Modifier and TypeField and Description
private final ReentrantLock
private long
private final DecoderInstructionsReader
private final DynamicTable
private static final AtomicLong
private final QueuingStreamPair
private long
private final ReentrantReadWriteLock
private final ConcurrentMap<Long, ConcurrentSkipListSet<Long>>
private final QPACK.Logger
private long
private final InsertionPolicy
private final QPACK.QPACKErrorHandler
private static final Set<String>
private final TablesIndexer
private final ConcurrentMap<Long, Queue<Encoder.SectionReference>>

Constructor Summary

AccessConstructor and Description
public
Encoder(InsertionPolicy policy, QPACK.StreamPairSupplier
supplier of the encoder unidirectional stream pair
streamPairs
,
QPACK.QPACKErrorHandler codingError)

Constructs an Encoder with zero initial capacity of the dynamic table.

Method Summary

Modifier and TypeMethod and Description
pack-priv long
private void
cleanupStreamData(long streamId)

public void
configure(ConnectionSettings
the peer settings
peerSettings
)

Configures encoder according to the settings received from the peer.

public List<ByteBuffer>
encodeHeaders(HeaderFrameWriter writer, long streamId, int bufferSize, HttpHeaders... headers)

public QueuingStreamPair
public void
private ByteBuffer
getByteBuffer(int size)

public void
header(Encoder.EncodingContext context, CharSequence name, CharSequence value, boolean sensitive)

public void
header(Encoder.EncodingContext
the encoding context
context
,
CharSequence
the name
name
,
CharSequence
the value
value
,
boolean
whether the value is sensitive
sensitive
,
long
the count of received entries known to a peer decoder or -1 to skip the dynamic table entry index check during header encoding.
knownReceivedCount
)

Sets up the given header (name, value) with possibly sensitive value.

public long
public Encoder.EncodingContext
newEncodingContext(long streamId, long base, HeaderFrameWriter writer)

public HeaderFrameWriter
private void
processDecoderAcks(ByteBuffer
data sent by the peer's decoder
buffer
)

This method is called when the peer decoder sends data on the peer's decoder stream

public void
registerUnackedFieldLineSection(long streamId, Encoder.SectionReference sectionReference)

public void
setTableCapacity(long
a non-negative long
capacity
)

Sets the capacity of the encoder's dynamic table and notifies the decoder by issuing "Set Dynamic Table Capacity" instruction.

public Encoder.SectionReference
private Encoder.SectionReference
private void
private void
updateKrcSectionAck(long streamId)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockedStreamsCounterLockback to summary
private final ReentrantLock blockedStreamsCounterLock
blockedStreamsInFlightback to summary
private long blockedStreamsInFlight
decoderInstructionsReaderback to summary
private final DecoderInstructionsReader decoderInstructionsReader
dynamicTableback to summary
private final DynamicTable dynamicTable
ENCODERS_IDSback to summary
private static final AtomicLong ENCODERS_IDS
encoderStreamsback to summary
private final QueuingStreamPair encoderStreams
knownReceivedCountback to summary
private long knownReceivedCount
krcLockback to summary
private final ReentrantReadWriteLock krcLock
liveContextReferencesback to summary
private final ConcurrentMap<Long, ConcurrentSkipListSet<Long>> liveContextReferences
loggerback to summary
private final QPACK.Logger logger
maxBlockedStreamsback to summary
private long maxBlockedStreams
policyback to summary
private final InsertionPolicy policy
qpackErrorHandlerback to summary
private final QPACK.QPACKErrorHandler qpackErrorHandler
SENSITIVE_HEADER_NAMESback to summary
private static final Set<String> SENSITIVE_HEADER_NAMES
tablesIndexerback to summary
private final TablesIndexer tablesIndexer
unacknowledgedSectionsback to summary
private final ConcurrentMap<Long, Queue<Encoder.SectionReference>> unacknowledgedSections

Constructor Detail

Encoderback to summary
public Encoder(InsertionPolicy policy, QPACK.StreamPairSupplier streamPairs, QPACK.QPACKErrorHandler codingError)

Constructs an Encoder with zero initial capacity of the dynamic table. Maximum dynamic table capacity is not initialized until peer (decoder) HTTP/3 settings frame is received (see Encoder#configure(ConnectionSettings)).

Dynamic table capacity values has to be agreed between decoder and encoder out-of-band, e.g. by a protocol that uses QPACK.

Maximum dynamic table capacity is determined by the value of SETTINGS_QPACK_MAX_TABLE_CAPACITY HTTP/3 setting sent by the decoder side (see 3.2.3. Maximum Dynamic Table Capacity).

An encoder informs the decoder of a change to the dynamic table capacity using the "Set Dynamic Table Capacity" instruction (see 4.3.1. Set Dynamic Table Capacity)

Parameters
streamPairs:QPACK.StreamPairSupplier

supplier of the encoder unidirectional stream pair

Exceptions
IllegalArgumentException:
if maxCapacity is negative
See Also
Encoder#configure(ConnectionSettings)

Method Detail

blockedStreamsCountback to summary
pack-priv long blockedStreamsCount()
cleanupStreamDataback to summary
private void cleanupStreamData(long streamId)
configureback to summary
public void configure(ConnectionSettings peerSettings)

Configures encoder according to the settings received from the peer.

Parameters
peerSettings:ConnectionSettings

the peer settings

encodeHeadersback to summary
public List<ByteBuffer> encodeHeaders(HeaderFrameWriter writer, long streamId, int bufferSize, HttpHeaders... headers)
encoderStreamsback to summary
public QueuingStreamPair encoderStreams()
generateFieldLineSectionPrefixback to summary
public void generateFieldLineSectionPrefix(Encoder.EncodingContext encodingContext, List<ByteBuffer> buffers)
getByteBufferback to summary
private ByteBuffer getByteBuffer(int size)
headerback to summary
public void header(Encoder.EncodingContext context, CharSequence name, CharSequence value, boolean sensitive) throws IllegalStateException
headerback to summary
public void header(Encoder.EncodingContext context, CharSequence name, CharSequence value, boolean sensitive, long knownReceivedCount) throws IllegalStateException

Sets up the given header (name, value) with possibly sensitive value.

If the value is sensitive (think security, secrecy, etc.) this encoder will compress it using a special representation (see 7.1.3. Never-Indexed Literals).

Fixates name and value for the duration of encoding.

Parameters
context:Encoder.EncodingContext

the encoding context

name:CharSequence

the name

value:CharSequence

the value

sensitive:boolean

whether the value is sensitive

knownReceivedCount:long

the count of received entries known to a peer decoder or -1 to skip the dynamic table entry index check during header encoding.

Exceptions
IllegalStateException:
if the encoder hasn't fully encoded the previous header, or hasn't yet started to encode it
NullPointerException:
if any of the arguments are null
See Also
DecodingCallback#onDecoded(CharSequence, CharSequence, boolean)
knownReceivedCountback to summary
public long knownReceivedCount()
newEncodingContextback to summary
public Encoder.EncodingContext newEncodingContext(long streamId, long base, HeaderFrameWriter writer)
newHeaderFrameWriterback to summary
public HeaderFrameWriter newHeaderFrameWriter()
processDecoderAcksback to summary
private void processDecoderAcks(ByteBuffer buffer)

This method is called when the peer decoder sends data on the peer's decoder stream

Parameters
buffer:ByteBuffer

data sent by the peer's decoder

registerUnackedFieldLineSectionback to summary
public void registerUnackedFieldLineSection(long streamId, Encoder.SectionReference sectionReference)
setTableCapacityback to summary
public void setTableCapacity(long capacity)

Sets the capacity of the encoder's dynamic table and notifies the decoder by issuing "Set Dynamic Table Capacity" instruction.

The value has to be agreed between decoder and encoder out-of-band, e.g. by a protocol that uses QPACK (see 4.3.1. Set Dynamic Table Capacity).

Parameters
capacity:long

a non-negative long

Exceptions
IllegalArgumentException:
if capacity is negative or exceeds the negotiated max capacity HTTP/3 setting
unackedFieldLineSectionsRangeback to summary
public Encoder.SectionReference unackedFieldLineSectionsRange(Encoder.EncodingContext context)
unackedFieldLineSectionsRangeback to summary
private Encoder.SectionReference unackedFieldLineSectionsRange(Encoder.SectionReference initial)
updateKrcInsertCountIncrementback to summary
private void updateKrcInsertCountIncrement(long increment)
updateKrcSectionAckback to summary
private void updateKrcSectionAck(long streamId)
jdk.internal.net.http.qpack back to summary

public Class Encoder.EncodingContext

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable

Field Summary

Modifier and TypeField and Description
pack-priv final long
pack-priv boolean
pack-priv final EncoderInstructionsWriter
pack-priv long
pack-priv long
pack-priv final ConcurrentSkipListSet<Long>
pack-priv final long
pack-priv final HeaderFrameWriter

Constructor Summary

AccessConstructor and Description
public
EncodingContext(long streamId, long base, HeaderFrameWriter writer)

Method Summary

Modifier and TypeMethod and Description
private boolean
public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

public Encoder.SectionReference
public void
public void
registerSessionReference(long absoluteEntryId)

public FieldSectionPrefix
public TableEntry
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseback to summary
pack-priv final long base
blockedDecoderExpectedback to summary
pack-priv boolean blockedDecoderExpected
encoderInstructionsWriterback to summary
pack-priv final EncoderInstructionsWriter encoderInstructionsWriter
maxIndexback to summary
pack-priv long maxIndex
minIndexback to summary
pack-priv long minIndex
referencedIndexesback to summary
pack-priv final ConcurrentSkipListSet<Long> referencedIndexes
streamIdback to summary
pack-priv final long streamId
writerback to summary
pack-priv final HeaderFrameWriter writer

Constructor Detail

EncodingContextback to summary
public EncodingContext(long streamId, long base, HeaderFrameWriter writer)

Method Detail

canReferenceNewEntryback to summary
private boolean canReferenceNewEntry()
closeback to summary
public void close()

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
evictionLimitback to summary
public Encoder.SectionReference evictionLimit()
referenceEntryback to summary
public void referenceEntry(TableEntry tableEntry)
registerSessionReferenceback to summary
public void registerSessionReference(long absoluteEntryId)
sectionPrefixback to summary
public FieldSectionPrefix sectionPrefix()
tryInsertEntryback to summary
public TableEntry tryInsertEntry(TableEntry entry)
jdk.internal.net.http.qpack back to summary

public final Record Encoder.SectionReference

extends Record
Class Inheritance
Record Components
min:long
minimum entry id referenced from a field lines section
max:long
maximum entry id referenced from a field lines section

Descriptor of entries range referenced from a field lines section.

Field Summary

Modifier and TypeField and Description
private final long
max

Record Component accessed by max().

maximum entry id referenced from a field lines section
private final long
min

Record Component accessed by min().

minimum entry id referenced from a field lines section

Constructor Summary

AccessConstructor and Description
public
SectionReference(long min, long max)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public boolean
fullyAcked(long knownReceiveCount)

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public long
max()

Record Component getter of max.

Record Component maximum entry id referenced from a field lines section

public long
min()

Record Component getter of min.

Record Component minimum entry id referenced from a field lines section

public static Encoder.SectionReference
public static Encoder.SectionReference
public Encoder.SectionReference
public Encoder.SectionReference
reduce(long entryId)

public boolean
public static Encoder.SectionReference
singleReference(long entryId)

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

maxback to summary
private final long max

Record Component accessed by max().

maximum entry id referenced from a field lines section

minback to summary
private final long min

Record Component accessed by min().

minimum entry id referenced from a field lines section

Constructor Detail

SectionReferenceback to summary
public SectionReference(long min, long max)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
fullyAckedback to summary
public boolean fullyAcked(long knownReceiveCount)
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

maxback to summary
public long max()

Record Component getter of max.

Record Component
maximum entry id referenced from a field lines section
minback to summary
public long min()

Record Component getter of min.

Record Component
minimum entry id referenced from a field lines section
noReferencesback to summary
public static Encoder.SectionReference noReferences()
ofback to summary
public static Encoder.SectionReference of(Encoder.EncodingContext context)
reduceback to summary
public Encoder.SectionReference reduce(Encoder.SectionReference other)
reduceback to summary
public Encoder.SectionReference reduce(long entryId)
referencesEntriesback to summary
public boolean referencesEntries()
singleReferenceback to summary
public static Encoder.SectionReference singleReference(long entryId)
toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

jdk.internal.net.http.qpack back to summary

private Class Encoder.TableUpdatesCallback

extends Object
implements Callback
Class Inheritance
All Implemented Interfaces
jdk.internal.net.http.qpack.readers.DecoderInstructionsReader.Callback

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

TableUpdatesCallbackback to summary
private TableUpdatesCallback()

Method Detail

onInsertCountIncrementback to summary
public void onInsertCountIncrement(long increment)

Implements jdk.internal.net.http.qpack.readers.DecoderInstructionsReader.Callback.onInsertCountIncrement.

Annotations
@Override
onSectionAckback to summary
public void onSectionAck(long streamId)

Implements jdk.internal.net.http.qpack.readers.DecoderInstructionsReader.Callback.onSectionAck.

Annotations
@Override
onStreamCancelback to summary
public void onStreamCancel(long streamId)

Implements jdk.internal.net.http.qpack.readers.DecoderInstructionsReader.Callback.onStreamCancel.

Annotations
@Override