Package io.github.mahmoudimus.http2
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-1enablePush- SETTINGS_ENABLE_PUSHmaxConcurrentStreams- SETTINGS_MAX_CONCURRENT_STREAMS, 0 to 2^32-1 orUNLIMITEDinitialWindowSize- SETTINGS_INITIAL_WINDOW_SIZE, 0 to 2^31-1maxFrameSize- SETTINGS_MAX_FRAME_SIZE, 2^14 to 2^24-1maxHeaderListSize- SETTINGS_MAX_HEADER_LIST_SIZE, 0 to 2^32-1 orUNLIMITEDenableConnectProtocol- 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuildsHttp2Settings, starting from the protocol's initial values. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Http2SettingsThe protocol's initial values.static final intThe initial HPACK table capacity in octets.static final intThe initial stream and connection credit in octets.static final intThe initial maximum frame payload in octets.static final intRFC 8441: extended CONNECT (including WebSockets).static final intThe SETTINGS_ENABLE_PUSH identifier.static final intThe SETTINGS_HEADER_TABLE_SIZE identifier.static final intThe SETTINGS_INITIAL_WINDOW_SIZE identifier.static final intThe SETTINGS_MAX_CONCURRENT_STREAMS identifier.static final intThe SETTINGS_MAX_FRAME_SIZE identifier.static final intThe SETTINGS_MAX_HEADER_LIST_SIZE identifier.static final intThe largest SETTINGS_MAX_FRAME_SIZE allowed, 2^24 - 1.static final intThe largest flow-control window and SETTINGS_INITIAL_WINDOW_SIZE, 2^31 - 1.static final longNo limit: the initial value of MAX_CONCURRENT_STREAMS and MAX_HEADER_LIST_SIZE. -
Constructor Summary
ConstructorsConstructorDescriptionHttp2Settings(long headerTableSize, boolean enablePush, long maxConcurrentStreams, int initialWindowSize, int maxFrameSize, long maxHeaderListSize) Source-compatible constructor for the original HTTP/2 settings.Http2Settings(long headerTableSize, boolean enablePush, long maxConcurrentStreams, int initialWindowSize, int maxFrameSize, long maxHeaderListSize, boolean enableConnectProtocol) Creates settings after checking their protocol ranges. -
Method Summary
Modifier and TypeMethodDescriptionapply(Frame.Settings frame) These settings updated by a peer's SETTINGS frame, values processed in order and unknown identifiers ignored.static Http2Settings.Builderbuilder()Starts a settings builder with the protocol defaults.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.booleanReturns the value of theenableConnectProtocolrecord component.booleanReturns the value of theenablePushrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.longReturns the value of theheaderTableSizerecord component.intReturns the value of theinitialWindowSizerecord component.longReturns the value of themaxConcurrentStreamsrecord component.intReturns the value of themaxFrameSizerecord component.longReturns the value of themaxHeaderListSizerecord component.Copies these settings into a builder.toFrame()A SETTINGS frame carryingchangedValues().final StringtoString()Returns a string representation of this record class.static voidvalidate(int id, long value) Checks one received setting (RFC 9113 §6.5.2).
-
Field Details
-
HEADER_TABLE_SIZE
public static final int HEADER_TABLE_SIZEThe SETTINGS_HEADER_TABLE_SIZE identifier.- See Also:
-
ENABLE_PUSH
public static final int ENABLE_PUSHThe SETTINGS_ENABLE_PUSH identifier.- See Also:
-
MAX_CONCURRENT_STREAMS
public static final int MAX_CONCURRENT_STREAMSThe SETTINGS_MAX_CONCURRENT_STREAMS identifier.- See Also:
-
INITIAL_WINDOW_SIZE
public static final int INITIAL_WINDOW_SIZEThe SETTINGS_INITIAL_WINDOW_SIZE identifier.- See Also:
-
MAX_FRAME_SIZE
public static final int MAX_FRAME_SIZEThe SETTINGS_MAX_FRAME_SIZE identifier.- See Also:
-
MAX_HEADER_LIST_SIZE
public static final int MAX_HEADER_LIST_SIZEThe SETTINGS_MAX_HEADER_LIST_SIZE identifier.- See Also:
-
ENABLE_CONNECT_PROTOCOL
public static final int ENABLE_CONNECT_PROTOCOLRFC 8441: extended CONNECT (including WebSockets).- See Also:
-
UNLIMITED
public static final long UNLIMITEDNo 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_SIZEThe initial HPACK table capacity in octets.- See Also:
-
DEFAULT_INITIAL_WINDOW_SIZE
public static final int DEFAULT_INITIAL_WINDOW_SIZEThe initial stream and connection credit in octets.- See Also:
-
DEFAULT_MAX_FRAME_SIZE
public static final int DEFAULT_MAX_FRAME_SIZEThe initial maximum frame payload in octets.- See Also:
-
MAX_MAX_FRAME_SIZE
public static final int MAX_MAX_FRAME_SIZEThe largest SETTINGS_MAX_FRAME_SIZE allowed, 2^24 - 1.- See Also:
-
MAX_WINDOW_SIZE
public static final int MAX_WINDOW_SIZEThe largest flow-control window and SETTINGS_INITIAL_WINDOW_SIZE, 2^31 - 1.- See Also:
-
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-1enablePush- whether server push is permittedmaxConcurrentStreams- the concurrent stream limit, or UNLIMITEDinitialWindowSize- the initial stream credit in octets, from 0 to 2^31-1maxFrameSize- the maximum frame payload in octets, from 2^14 to 2^24-1maxHeaderListSize- 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-1enablePush- whether server push is permittedmaxConcurrentStreams- the concurrent stream limit, or UNLIMITEDinitialWindowSize- the initial stream credit in octets, from 0 to 2^31-1maxFrameSize- the maximum frame payload in octets, from 2^14 to 2^24-1maxHeaderListSize- the decoded field section limit in octets, or UNLIMITEDenableConnectProtocol- whether extended CONNECT is permitted
-
-
Method Details
-
builder
Starts a settings builder with the protocol defaults.- Returns:
- a new builder containing the default settings
-
toBuilder
Copies these settings into a builder.- Returns:
- a new builder containing these settings
-
validate
Checks one received setting (RFC 9113 §6.5.2). Unknown identifiers are accepted, since they must be ignored.- Parameters:
id- the received setting identifiervalue- 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
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
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
A SETTINGS frame carryingchangedValues().- Returns:
- a non-ACK frame containing the settings that differ from defaults
-
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. -
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. -
equals
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 '=='. -
headerTableSize
public long headerTableSize()Returns the value of theheaderTableSizerecord component.- Returns:
- the value of the
headerTableSizerecord component
-
enablePush
public boolean enablePush()Returns the value of theenablePushrecord component.- Returns:
- the value of the
enablePushrecord component
-
maxConcurrentStreams
public long maxConcurrentStreams()Returns the value of themaxConcurrentStreamsrecord component.- Returns:
- the value of the
maxConcurrentStreamsrecord component
-
initialWindowSize
public int initialWindowSize()Returns the value of theinitialWindowSizerecord component.- Returns:
- the value of the
initialWindowSizerecord component
-
maxFrameSize
public int maxFrameSize()Returns the value of themaxFrameSizerecord component.- Returns:
- the value of the
maxFrameSizerecord component
-
maxHeaderListSize
public long maxHeaderListSize()Returns the value of themaxHeaderListSizerecord component.- Returns:
- the value of the
maxHeaderListSizerecord component
-
enableConnectProtocol
public boolean enableConnectProtocol()Returns the value of theenableConnectProtocolrecord component.- Returns:
- the value of the
enableConnectProtocolrecord component
-