Record Class Http2Settings

java.lang.Object
java.lang.Record
io.github.mahmoudimus.http2.Http2Settings
Record Components:
headerTableSize - SETTINGS_HEADER_TABLE_SIZE: the largest HPACK dynamic table the sender of these settings lets its peer's encoder use, 0 to 2^32-1
enablePush - SETTINGS_ENABLE_PUSH
maxConcurrentStreams - SETTINGS_MAX_CONCURRENT_STREAMS, 0 to 2^32-1 or UNLIMITED
initialWindowSize - SETTINGS_INITIAL_WINDOW_SIZE, 0 to 2^31-1
maxFrameSize - SETTINGS_MAX_FRAME_SIZE, 2^14 to 2^24-1
maxHeaderListSize - SETTINGS_MAX_HEADER_LIST_SIZE, 0 to 2^32-1 or UNLIMITED
enableConnectProtocol - SETTINGS_ENABLE_CONNECT_PROTOCOL (RFC 8441)

public record Http2Settings(long headerTableSize, boolean enablePush, long maxConcurrentStreams, int initialWindowSize, int maxFrameSize, long maxHeaderListSize, boolean enableConnectProtocol) extends Record
The SETTINGS parameters of one endpoint (RFC 9113 §6.5.2). Immutable; the constructor and Http2Settings.Builder.build() reject values the protocol does not allow with IllegalArgumentException, and apply(Frame.Settings) rejects a peer's invalid values with the Http2Exception the protocol requires.

DEFAULT holds the protocol's initial values, which are in force for each direction until a SETTINGS frame changes them. UNLIMITED stands for "no limit", the initial value of maxConcurrentStreams and maxHeaderListSize.

  • Field Details

    • HEADER_TABLE_SIZE

      public static final int HEADER_TABLE_SIZE
      The SETTINGS_HEADER_TABLE_SIZE identifier.
      See Also:
    • ENABLE_PUSH

      public static final int ENABLE_PUSH
      The SETTINGS_ENABLE_PUSH identifier.
      See Also:
    • MAX_CONCURRENT_STREAMS

      public static final int MAX_CONCURRENT_STREAMS
      The SETTINGS_MAX_CONCURRENT_STREAMS identifier.
      See Also:
    • INITIAL_WINDOW_SIZE

      public static final int INITIAL_WINDOW_SIZE
      The SETTINGS_INITIAL_WINDOW_SIZE identifier.
      See Also:
    • MAX_FRAME_SIZE

      public static final int MAX_FRAME_SIZE
      The SETTINGS_MAX_FRAME_SIZE identifier.
      See Also:
    • MAX_HEADER_LIST_SIZE

      public static final int MAX_HEADER_LIST_SIZE
      The SETTINGS_MAX_HEADER_LIST_SIZE identifier.
      See Also:
    • ENABLE_CONNECT_PROTOCOL

      public static final int ENABLE_CONNECT_PROTOCOL
      RFC 8441: extended CONNECT (including WebSockets).
      See Also:
    • UNLIMITED

      public static final long UNLIMITED
      No limit: the initial value of MAX_CONCURRENT_STREAMS and MAX_HEADER_LIST_SIZE.
      See Also:
    • DEFAULT_HEADER_TABLE_SIZE

      public static final int DEFAULT_HEADER_TABLE_SIZE
      The initial HPACK table capacity in octets.
      See Also:
    • DEFAULT_INITIAL_WINDOW_SIZE

      public static final int DEFAULT_INITIAL_WINDOW_SIZE
      The initial stream and connection credit in octets.
      See Also:
    • DEFAULT_MAX_FRAME_SIZE

      public static final int DEFAULT_MAX_FRAME_SIZE
      The initial maximum frame payload in octets.
      See Also:
    • MAX_MAX_FRAME_SIZE

      public static final int MAX_MAX_FRAME_SIZE
      The largest SETTINGS_MAX_FRAME_SIZE allowed, 2^24 - 1.
      See Also:
    • MAX_WINDOW_SIZE

      public static final int MAX_WINDOW_SIZE
      The largest flow-control window and SETTINGS_INITIAL_WINDOW_SIZE, 2^31 - 1.
      See Also:
    • DEFAULT

      public static final Http2Settings DEFAULT
      The protocol's initial values.
  • Constructor Details

    • Http2Settings

      public Http2Settings(long headerTableSize, boolean enablePush, long maxConcurrentStreams, int initialWindowSize, int maxFrameSize, long maxHeaderListSize)
      Source-compatible constructor for the original HTTP/2 settings.
      Parameters:
      headerTableSize - the peer HPACK table limit in octets, from 0 to 2^32-1
      enablePush - whether server push is permitted
      maxConcurrentStreams - the concurrent stream limit, or UNLIMITED
      initialWindowSize - the initial stream credit in octets, from 0 to 2^31-1
      maxFrameSize - the maximum frame payload in octets, from 2^14 to 2^24-1
      maxHeaderListSize - the decoded field section limit in octets, or UNLIMITED
    • Http2Settings

      public Http2Settings(long headerTableSize, boolean enablePush, long maxConcurrentStreams, int initialWindowSize, int maxFrameSize, long maxHeaderListSize, boolean enableConnectProtocol)
      Creates settings after checking their protocol ranges.
      Parameters:
      headerTableSize - the peer HPACK table limit in octets, from 0 to 2^32-1
      enablePush - whether server push is permitted
      maxConcurrentStreams - the concurrent stream limit, or UNLIMITED
      initialWindowSize - the initial stream credit in octets, from 0 to 2^31-1
      maxFrameSize - the maximum frame payload in octets, from 2^14 to 2^24-1
      maxHeaderListSize - the decoded field section limit in octets, or UNLIMITED
      enableConnectProtocol - whether extended CONNECT is permitted
  • Method Details

    • builder

      public static Http2Settings.Builder builder()
      Starts a settings builder with the protocol defaults.
      Returns:
      a new builder containing the default settings
    • toBuilder

      public Http2Settings.Builder toBuilder()
      Copies these settings into a builder.
      Returns:
      a new builder containing these settings
    • validate

      public static void validate(int id, long value) throws Http2Exception
      Checks one received setting (RFC 9113 §6.5.2). Unknown identifiers are accepted, since they must be ignored.
      Parameters:
      id - the received setting identifier
      value - the unsigned 32-bit wire value
      Throws:
      Http2Exception - a connection error: PROTOCOL_ERROR for a bad ENABLE_PUSH or MAX_FRAME_SIZE, FLOW_CONTROL_ERROR for an INITIAL_WINDOW_SIZE above 2^31-1
    • apply

      public Http2Settings apply(Frame.Settings frame) throws Http2Exception
      These settings updated by a peer's SETTINGS frame, values processed in order and unknown identifiers ignored. An ACK changes nothing.
      Parameters:
      frame - the received SETTINGS frame
      Returns:
      the updated settings, or these settings for an ACK
      Throws:
      Http2Exception - if a setting is invalid or attempts to disable extended CONNECT
    • changedValues

      public Map<Integer,Long> changedValues()
      The values that differ from the protocol's initial ones, in identifier order: what a SETTINGS frame must carry to establish these settings on a new connection.
      Returns:
      the settings that differ from the defaults, in identifier order
    • toFrame

      public Frame.Settings toFrame()
      A SETTINGS frame carrying changedValues().
      Returns:
      a non-ACK frame containing the settings that differ from defaults
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • headerTableSize

      public long headerTableSize()
      Returns the value of the headerTableSize record component.
      Returns:
      the value of the headerTableSize record component
    • enablePush

      public boolean enablePush()
      Returns the value of the enablePush record component.
      Returns:
      the value of the enablePush record component
    • maxConcurrentStreams

      public long maxConcurrentStreams()
      Returns the value of the maxConcurrentStreams record component.
      Returns:
      the value of the maxConcurrentStreams record component
    • initialWindowSize

      public int initialWindowSize()
      Returns the value of the initialWindowSize record component.
      Returns:
      the value of the initialWindowSize record component
    • maxFrameSize

      public int maxFrameSize()
      Returns the value of the maxFrameSize record component.
      Returns:
      the value of the maxFrameSize record component
    • maxHeaderListSize

      public long maxHeaderListSize()
      Returns the value of the maxHeaderListSize record component.
      Returns:
      the value of the maxHeaderListSize record component
    • enableConnectProtocol

      public boolean enableConnectProtocol()
      Returns the value of the enableConnectProtocol record component.
      Returns:
      the value of the enableConnectProtocol record component