Package io.github.mahmoudimus.http3
Class Http3StreamType
java.lang.Object
io.github.mahmoudimus.http3.Http3StreamType
The types of unidirectional streams (RFC 9114 §6.2, RFC 9204 §4.2): each such stream starts
with its type as a variable-length integer. Bidirectional streams have no type; in HTTP/3 they
are all request streams.
Http3StreamValidator.UnidirectionalStreams checks the rules on
how many of each type a peer may open.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe control stream: SETTINGS first, then GOAWAY, MAX_PUSH_ID, CANCEL_PUSH and extensions.static final longA push stream: a push ID, then the pushed response (server to client only).static final longThe QPACK decoder stream: decoder instructions, forQpackEncoder.onDecoderStream(byte[]).static final longThe QPACK encoder stream: encoder instructions, forQpackDecoder.onEncoderStream(byte[]). -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]encode(long type) The bytes that open a unidirectional stream of this type.static booleanisCritical(long type) Whether closing a stream of this type is a connection error H3_CLOSED_CRITICAL_STREAM.static booleanisKnown(long type) Whether the type is one of the four defined ones.static booleanisReserved(long type) Whether the type is reserved for greasing, 0x1f * N + 0x21 (§6.2.3).static Stringname(long type) A readable name for a stream type, for messages.static longread(InputStream in) Reads a stream type from the start of a unidirectional stream.
-
Field Details
-
CONTROL
public static final long CONTROLThe control stream: SETTINGS first, then GOAWAY, MAX_PUSH_ID, CANCEL_PUSH and extensions.- See Also:
-
PUSH
public static final long PUSHA push stream: a push ID, then the pushed response (server to client only).- See Also:
-
QPACK_ENCODER
public static final long QPACK_ENCODERThe QPACK encoder stream: encoder instructions, forQpackDecoder.onEncoderStream(byte[]).- See Also:
-
QPACK_DECODER
public static final long QPACK_DECODERThe QPACK decoder stream: decoder instructions, forQpackEncoder.onDecoderStream(byte[]).- See Also:
-
-
Method Details
-
isReserved
public static boolean isReserved(long type) Whether the type is reserved for greasing, 0x1f * N + 0x21 (§6.2.3). Such streams carry no meaning; the receiver discards or abandons them.- Parameters:
type- the stream type- Returns:
- whether it is reserved
-
isKnown
public static boolean isKnown(long type) Whether the type is one of the four defined ones.- Parameters:
type- the stream type- Returns:
- whether it is defined
-
isCritical
public static boolean isCritical(long type) Whether closing a stream of this type is a connection error H3_CLOSED_CRITICAL_STREAM.- Parameters:
type- the stream type- Returns:
- whether the connection needs the stream
-
read
Reads a stream type from the start of a unidirectional stream.- Parameters:
in- the stream- Returns:
- the type, or -1 if the stream ended before all of it arrived, which a receiver must tolerate (§6.2)
- Throws:
IOException- if reading fails
-
encode
public static byte[] encode(long type) The bytes that open a unidirectional stream of this type.- Parameters:
type- the stream type- Returns:
- its encoding
-
name
A readable name for a stream type, for messages.- Parameters:
type- the stream type- Returns:
- its name
-