pub struct Http2OptionsBuilder { /* private fields */ }Expand description
Builder for Http2Options.
Implementations§
Source§impl Http2OptionsBuilder
impl Http2OptionsBuilder
Sourcepub fn initial_window_size(self, sz: impl Into<Option<u32>>) -> Self
pub fn initial_window_size(self, sz: impl Into<Option<u32>>) -> Self
Sets the SETTINGS_INITIAL_WINDOW_SIZE option for HTTP2
stream-level flow control.
Passing None will do nothing.
If not set, crate::core: will use a default.
Sourcepub fn initial_connection_window_size(self, sz: impl Into<Option<u32>>) -> Self
pub fn initial_connection_window_size(self, sz: impl Into<Option<u32>>) -> Self
Sets the max connection-level flow control for HTTP2
Passing None will do nothing.
If not set, crate::core: will use a default.
Sourcepub fn initial_max_send_streams(self, initial: impl Into<Option<usize>>) -> Self
pub fn initial_max_send_streams(self, initial: impl Into<Option<usize>>) -> Self
Sets the initial maximum of locally initiated (send) streams.
This value will be overwritten by the value included in the initial SETTINGS frame received from the peer as part of a connection preface.
Passing None will do nothing.
If not set, crate::core: will use a default.
Sourcepub fn initial_stream_id(self, id: impl Into<Option<u32>>) -> Self
pub fn initial_stream_id(self, id: impl Into<Option<u32>>) -> Self
Sets the initial stream id for the connection.
Sourcepub fn adaptive_window(self, enabled: bool) -> Self
pub fn adaptive_window(self, enabled: bool) -> Self
Sets whether to use an adaptive flow control.
Enabling this will override the limits set in
initial_stream_window_size and
initial_connection_window_size.
Sourcepub fn max_frame_size(self, sz: impl Into<Option<u32>>) -> Self
pub fn max_frame_size(self, sz: impl Into<Option<u32>>) -> Self
Sets the maximum frame size to use for HTTP2.
Default is currently 16KB, but can change.
Sourcepub fn max_header_list_size(self, max: u32) -> Self
pub fn max_header_list_size(self, max: u32) -> Self
Sets the max size of received header frames.
Default is currently 16KB, but can change.
Sourcepub fn header_table_size(self, size: impl Into<Option<u32>>) -> Self
pub fn header_table_size(self, size: impl Into<Option<u32>>) -> Self
Sets the header table size.
This setting informs the peer of the maximum size of the header compression table used to encode header blocks, in octets. The encoder may select any value equal to or less than the header table size specified by the sender.
The default value of crate h2 is 4,096.
Sourcepub fn max_concurrent_streams(self, max: impl Into<Option<u32>>) -> Self
pub fn max_concurrent_streams(self, max: impl Into<Option<u32>>) -> Self
Sets the maximum number of concurrent streams.
The maximum concurrent streams setting only controls the maximum number of streams that can be initiated by the remote peer. In other words, when this setting is set to 100, this does not limit the number of concurrent streams that can be created by the caller.
It is recommended that this value be no smaller than 100, so as to not
unnecessarily limit parallelism. However, any value is legal, including
0. If max is set to 0, then the remote will not be permitted to
initiate streams.
Note that streams in the reserved state, i.e., push promises that have been reserved but the stream has not started, do not count against this setting.
Also note that if the remote does exceed the value set here, it is not
a protocol level error. Instead, the h2 library will immediately reset
the stream.
See Section 5.1.2 in the HTTP/2 spec for more details.
Sourcepub fn keep_alive_interval(self, interval: impl Into<Option<Duration>>) -> Self
pub fn keep_alive_interval(self, interval: impl Into<Option<Duration>>) -> Self
Sets an interval for HTTP2 Ping frames should be sent to keep a connection alive.
Pass None to disable HTTP2 keep-alive.
Default is currently disabled.
Sourcepub fn keep_alive_timeout(self, timeout: Duration) -> Self
pub fn keep_alive_timeout(self, timeout: Duration) -> Self
Sets a timeout for receiving an acknowledgement of the keep-alive ping.
If the ping is not acknowledged within the timeout, the connection will
be closed. Does nothing if keep_alive_interval is disabled.
Default is 20 seconds.
Sourcepub fn keep_alive_while_idle(self, enabled: bool) -> Self
pub fn keep_alive_while_idle(self, enabled: bool) -> Self
Sets whether HTTP2 keep-alive should apply while the connection is idle.
If disabled, keep-alive pings are only sent while there are open
request/responses streams. If enabled, pings are also sent when no
streams are active. Does nothing if keep_alive_interval is
disabled.
Default is false.
Sourcepub fn enable_push(self, opt: bool) -> Self
pub fn enable_push(self, opt: bool) -> Self
Enables and disables the push feature for HTTP2.
Passing None will do nothing.
Sourcepub fn enable_connect_protocol(self, opt: bool) -> Self
pub fn enable_connect_protocol(self, opt: bool) -> Self
Sets the enable connect protocol.
Sourcepub fn no_rfc7540_priorities(self, opt: bool) -> Self
pub fn no_rfc7540_priorities(self, opt: bool) -> Self
Disable RFC 7540 Stream Priorities (set to true to disable).
[RFC 9218]: https://www.rfc-editor.org/rfc/rfc9218.html#section-2.1
Sourcepub fn max_concurrent_reset_streams(self, max: usize) -> Self
pub fn max_concurrent_reset_streams(self, max: usize) -> Self
Sets the maximum number of HTTP2 concurrent locally reset streams.
See the documentation of http2::client::Builder::max_concurrent_reset_streams for more
details.
The default value is determined by the h2 crate.
Sourcepub fn max_send_buf_size(self, max: usize) -> Self
pub fn max_send_buf_size(self, max: usize) -> Self
Set the maximum write buffer size for each HTTP/2 stream.
Default is currently 1MB, but may change.
§Panics
The value must be no larger than u32::MAX.
Sourcepub fn max_pending_accept_reset_streams(
self,
max: impl Into<Option<usize>>,
) -> Self
pub fn max_pending_accept_reset_streams( self, max: impl Into<Option<usize>>, ) -> Self
Configures the maximum number of pending reset streams allowed before a GOAWAY will be sent.
See https://github.com/hyperium/hyper/issues/2877 for more information.
Sourcepub fn headers_stream_dependency<T>(self, stream_dependency: T) -> Self
pub fn headers_stream_dependency<T>(self, stream_dependency: T) -> Self
Sets the stream dependency and weight for the outgoing HEADERS frame.
This configures the priority of the stream by specifying its dependency and weight, as defined by the HTTP/2 priority mechanism. This can be used to influence how the server allocates resources to this stream relative to others.
Sourcepub fn headers_pseudo_order<T>(self, headers_pseudo_order: T) -> Self
pub fn headers_pseudo_order<T>(self, headers_pseudo_order: T) -> Self
Sets the HTTP/2 pseudo-header field order for outgoing HEADERS frames.
This determines the order in which pseudo-header fields (such as :method, :scheme, etc.)
are encoded in the HEADERS frame. Customizing the order may be useful for interoperability
or testing purposes.
Sourcepub fn settings_order<T>(self, settings_order: T) -> Self
pub fn settings_order<T>(self, settings_order: T) -> Self
Sets the order of settings parameters in the initial SETTINGS frame.
This determines the order in which settings are sent during the HTTP/2 handshake. Customizing the order may be useful for testing or protocol compliance.
Sourcepub fn priorities<T>(self, priorities: T) -> Self
pub fn priorities<T>(self, priorities: T) -> Self
Sets the list of PRIORITY frames to be sent immediately after the connection is established, but before the first request is sent.
This allows you to pre-configure the HTTP/2 stream dependency tree by specifying a set of PRIORITY frames that will be sent as part of the connection preface. This can be useful for optimizing resource allocation or testing custom stream prioritization strategies.
Each Priority in the list must have a valid (non-zero) stream ID. Any priority with a
stream ID of zero will be ignored.
Sourcepub fn build(self) -> Http2Options
pub fn build(self) -> Http2Options
Builds the Http2Options instance.