Struct Http2ServiceConfig
pub struct Http2ServiceConfig { /* private fields */ }Expand description
HTTP/2 connection and service configuration.
Implementations§
§impl ServiceConfig
impl ServiceConfig
pub fn new() -> ServiceConfig
pub fn new() -> ServiceConfig
Creates a configuration with HTTP/2 defaults.
§impl ServiceConfig
impl ServiceConfig
pub fn set_initial_window_size(self, size: i32) -> ServiceConfig
pub fn set_initial_window_size(self, size: i32) -> ServiceConfig
Indicates the initial window size (in octets) for stream-level flow control for received data.
The initial window of a stream is used as part of flow control. For more details, see flow control.
The default value is 65,535.
§Panics
Panics if size is negative.
pub fn set_initial_connection_window_size(self, size: i32) -> ServiceConfig
pub fn set_initial_connection_window_size(self, size: i32) -> ServiceConfig
Indicates the initial window size (in octets) for connection-level flow control for received data.
The initial window of a connection is used as part of flow control. For more details, see flow control.
The window is released when received data is consumed, so it bounds the amount of unconsumed data buffered for all streams of the connection.
The connection window starts at 65,535 and can only be increased with
WINDOW_UPDATE frames, smaller values do not shrink it.
The default value is 4 MiB.
§Panics
Panics if size is negative.
pub fn set_max_frame_size(self, max: u32) -> ServiceConfig
pub fn set_max_frame_size(self, max: u32) -> ServiceConfig
Indicates the size (in octets) of the largest HTTP/2 frame payload that the local endpoint is able to accept.
The value is advertised to the peer with SETTINGS_MAX_FRAME_SIZE, the
peer must split larger payloads into multiple frames. Frames sent to the
peer are limited by the peer’s own setting.
The value must be between 16,384 and 16,777,215. The default value is 16,384.
§Panics
This function panics if max is not within the legal range specified
above.
pub fn set_max_headers(self, val: usize) -> ServiceConfig
pub fn set_max_headers(self, val: usize) -> ServiceConfig
Set the maximum number of headers.
When a request is received, the parser will reserve a buffer to store headers for optimal performance.
If a header block contains more headers than the buffer size, the
stream is reset with REFUSED_STREAM reason.
The default is 96.
pub fn set_max_header_list_size(self, max: u32) -> ServiceConfig
pub fn set_max_header_list_size(self, max: u32) -> ServiceConfig
Sets the maximum decoded header-list size.
This advisory setting informs a peer of the maximum size of header list that the sender is prepared to accept, in octets. The value is based on the uncompressed size of header fields, including the length of the name and value in octets plus an overhead of 32 octets for each header field.
This setting is also used to limit the maximum amount of data that is buffered to decode HEADERS frames.
The default is 48 KiB.
pub fn set_max_header_continuation_frames(self, max: usize) -> ServiceConfig
pub fn set_max_header_continuation_frames(self, max: usize) -> ServiceConfig
Sets the maximum number of continuation frames for one header block.
The default is 5.
pub fn set_max_concurrent_streams(self, max: u32) -> ServiceConfig
pub fn set_max_concurrent_streams(self, max: u32) -> ServiceConfig
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.
If the remote exceeds the value set here, the stream is reset with
REFUSED_STREAM. Refused streams count toward the rapid-reset limit,
once at least 10 streams have been opened and half of them are reset
the connection is closed with GOAWAY
(ConnectionError::StreamResetsLimit).
The default value is 256.
See Section 5.1.2 in the HTTP/2 spec for more details.
pub fn set_max_concurrent_reset_streams(self, val: usize) -> ServiceConfig
pub fn set_max_concurrent_reset_streams(self, val: usize) -> ServiceConfig
Sets the maximum number of concurrent locally reset streams.
When a stream is explicitly reset, or an unfinished stream handle is dropped, HTTP/2 requires further frames for that stream to be ignored for a period of time.
In order to satisfy the specification, internal state must be maintained to implement the behavior. This state grows linearly with the number of streams that are locally reset.
This setting configures an upper bound on the amount of state that is maintained. When this max value is reached, the oldest reset stream is purged from memory.
Once the stream has been fully purged from memory, any additional DATA
or WINDOW_UPDATE frames received for that stream will result in a
connection level protocol error, forcing the connection to terminate.
RST_STREAM and PRIORITY frames are ignored.
The default value is 32.
pub fn set_reset_stream_duration(self, dur: Seconds) -> ServiceConfig
pub fn set_reset_stream_duration(self, dur: Seconds) -> ServiceConfig
Sets how long locally reset stream state is retained.
When a stream is explicitly reset, or an unfinished stream handle is dropped, HTTP/2 requires further frames for that stream to be ignored for a period of time.
In order to satisfy the specification, internal state must be maintained to implement the behavior. This state grows linearly with the number of streams that are locally reset.
The reset_stream_duration setting configures the max amount of time
this state will be maintained in memory. Once the duration elapses, the
stream state is purged from memory.
Once the stream has been fully purged from memory, any additional DATA
or WINDOW_UPDATE frames received for that stream will result in a
connection level protocol error, forcing the connection to terminate.
RST_STREAM and PRIORITY frames are ignored.
The default value is 30 seconds.
pub fn set_handshake_timeout(self, timeout: Seconds) -> ServiceConfig
pub fn set_handshake_timeout(self, timeout: Seconds) -> ServiceConfig
Sets the connection handshake timeout.
For servers the handshake includes receiving the client preface and
creating the request service. For clients created by
client::Connector it includes establishing
the transport and creating the connection. The connections pool uses
ClientBuilder::connect_timeout
instead.
A zero duration disables the timeout. The default is 5 seconds.
pub fn set_ping_timeout(self, timeout: Seconds) -> ServiceConfig
pub fn set_ping_timeout(self, timeout: Seconds) -> ServiceConfig
Sets the keep-alive ping timeout.
A PING frame is sent to the peer every timeout interval. If the
previous PING is not acknowledged by the next interval, the connection
is closed and the open streams fail with
ConnectionError::KeepaliveTimeout.
A zero duration disables keep-alive pings. The default is 10 seconds.
pub fn set_settings_timeout(self, timeout: Seconds) -> ServiceConfig
pub fn set_settings_timeout(self, timeout: Seconds) -> ServiceConfig
Sets the local settings acknowledgment timeout.
If the peer does not acknowledge the local SETTINGS frame in time, the
connection is closed with SETTINGS_TIMEOUT (RFC 9113 §6.5.3) and the
open streams fail with
ConnectionError::SettingsTimeout.
A zero duration disables the timeout. The default is 5 seconds.
pub fn set_capacity_timeout(self, timeout: Seconds) -> ServiceConfig
pub fn set_capacity_timeout(self, timeout: Seconds) -> ServiceConfig
Sets the send-capacity availability timeout.
A stream that waits for send capacity longer than the timeout is reset with
CANCEL, the waiter fails with StreamError::CapacityTimeout. The final
message of a remote stream is published only if the stream has a publish
call in flight, see StreamRef::reset.
A zero duration disables the timeout. The default is 5 seconds.
pub fn set_max_inflight_messages(self, max: u16) -> ServiceConfig
pub fn set_max_inflight_messages(self, max: u16) -> ServiceConfig
Sets the maximum number of in-flight service calls of a connection.
Every received HEADERS, DATA or trailers frame is published to the service, control events are counted as well. Once the limit is reached the connection stops processing incoming frames until a call completes.
The value must be between 1 and 32,767. The default value is 8,192.
§Panics
Panics if max is not within the range specified above.
§impl ServiceConfig
impl ServiceConfig
pub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Returns whether shutdown has been requested on the current thread.
pub fn shutdown()
pub fn shutdown()
Requests shutdown for services running on the current thread.
The flag is global for the thread and cannot be reset. Server
connections check it when their dispatcher is polled next and then
disconnect gracefully, new streams are refused with REFUSED_STREAM and
the connection is closed after the open streams complete. Client
connections do not check the flag.