Class Http3StreamType

java.lang.Object
io.github.mahmoudimus.http3.Http3StreamType

public final class Http3StreamType extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static final long
    The control stream: SETTINGS first, then GOAWAY, MAX_PUSH_ID, CANCEL_PUSH and extensions.
    static final long
    A push stream: a push ID, then the pushed response (server to client only).
    static final long
    The QPACK decoder stream: decoder instructions, for QpackEncoder.onDecoderStream(byte[]).
    static final long
    The QPACK encoder stream: encoder instructions, for QpackDecoder.onEncoderStream(byte[]).
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    encode(long type)
    The bytes that open a unidirectional stream of this type.
    static boolean
    isCritical(long type)
    Whether closing a stream of this type is a connection error H3_CLOSED_CRITICAL_STREAM.
    static boolean
    isKnown(long type)
    Whether the type is one of the four defined ones.
    static boolean
    isReserved(long type)
    Whether the type is reserved for greasing, 0x1f * N + 0x21 (§6.2.3).
    static String
    name(long type)
    A readable name for a stream type, for messages.
    static long
    Reads a stream type from the start of a unidirectional stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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

      public static long read(InputStream in) throws IOException
      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

      public static String name(long type)
      A readable name for a stream type, for messages.
      Parameters:
      type - the stream type
      Returns:
      its name