pub struct Config { /* private fields */ }Implementations§
Source§impl Config
impl Config
Sourcepub fn initial_stream_window_size(self, sz: impl Into<Option<u32>>) -> Self
pub fn initial_stream_window_size(self, sz: impl Into<Option<u32>>) -> Self
Sets the SETTINGS_INITIAL_WINDOW_SIZE option for HTTP2
stream-level flow control.
If None is specified, hyper’s default is used (currently 1 MiB;
the HTTP/2 spec default of 65,535 bytes only applies to
implementations that never adjust it).
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
If None is specified, hyper’s default is used (currently 1 MiB).
Note that hyper’s default equals the per-stream window, so a single stream stalled mid-upload can pin the entire connection receive window and starve every other stream on the connection. Workloads with large or streaming request bodies should consider raising this to a multiple of the stream window.
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 SETTINGS_MAX_CONCURRENT_STREAMS option for HTTP2
connections.
Default is 200, matching hyper’s hardened default. Passing None
removes the limit entirely and advertises unlimited concurrent
streams to the peer; this makes the server vulnerable to
Rapid-Reset-style resource exhaustion and should be an explicit,
deliberate choice.
Sourcepub fn max_connection_age(self, max_connection_age: Duration) -> Self
pub fn max_connection_age(self, max_connection_age: Duration) -> Self
Sets the maximum time option in milliseconds that a connection may exist
When a connection reaches its maximum age it is shut down
gracefully: for HTTP/2 a GOAWAY is sent, and in-flight requests are
allowed to complete. See Config::max_connection_age_grace for
bounding how long that completion may take.
Default is no limit (None).
Sourcepub fn max_connection_age_grace(
self,
max_connection_age_grace: Duration,
) -> Self
pub fn max_connection_age_grace( self, max_connection_age_grace: Duration, ) -> Self
Sets the grace period allowed after a graceful shutdown of a connection is initiated before the connection is forcefully closed.
The grace period applies however the graceful shutdown was
triggered: Config::max_connection_age expiring,
ConnectionInfo::close, or ServerHandle::trigger_shutdown.
A graceful shutdown waits for in-flight requests to complete, but a
stream that can make no progress – for example, a response wedged
behind HTTP/2 flow-control windows that a stalled or vanished peer
never reopens – would keep the connection alive forever. Once the
grace period expires the connection is dropped along with any
streams still in flight, following the semantics of grpc-go’s
MAX_CONNECTION_AGE_GRACE. This is the only server-side mechanism
that reclaims send-stalled streams: middleware cannot do it because
the response body is no longer polled once the stream stalls.
Default is an unlimited grace period (None): the connection stays
open until every in-flight request completes.
Sourcepub fn http2_keepalive_interval(
self,
http2_keepalive_interval: Option<Duration>,
) -> Self
pub fn http2_keepalive_interval( self, http2_keepalive_interval: Option<Duration>, ) -> Self
Set whether HTTP2 Ping frames are enabled on accepted connections.
If None is specified, HTTP2 keepalive is disabled, otherwise the duration
specified will be the time interval between HTTP2 Ping frames.
The timeout for receiving an acknowledgement of the keepalive ping
can be set with Config::http2_keepalive_timeout.
Default is no HTTP2 keepalive (None)
Sourcepub fn http2_keepalive_timeout(
self,
http2_keepalive_timeout: Option<Duration>,
) -> Self
pub fn http2_keepalive_timeout( self, http2_keepalive_timeout: Option<Duration>, ) -> Self
Sets a timeout for receiving an acknowledgement of the keepalive ping.
If the ping is not acknowledged within the timeout, the connection will be closed. Does nothing if http2_keep_alive_interval is disabled.
Default is 20 seconds.
Sourcepub fn http2_adaptive_window(self, enabled: Option<bool>) -> Self
pub fn http2_adaptive_window(self, enabled: Option<bool>) -> Self
Sets whether to use an adaptive flow control. Defaults to false. Enabling this will override the limits set in http2_initial_stream_window_size and http2_initial_connection_window_size.
Warning: enabling this resets both receive windows to the HTTP/2 spec default of 65,535 bytes until BDP probing ramps them back up. Until then the whole connection has a single stalled stream’s worth of window, so one slow reader can starve every other stream on the connection. For multiplexed streaming workloads this measurably underperforms the static defaults; prefer setting explicit window sizes instead.
Sourcepub fn http2_max_pending_accept_reset_streams(self, max: Option<usize>) -> Self
pub fn http2_max_pending_accept_reset_streams(self, max: Option<usize>) -> Self
Configures the maximum number of pending reset streams allowed before a GOAWAY will be sent.
This will default to whatever the default in h2 is. As of v0.3.17, it is 20.
See https://github.com/hyperium/hyper/issues/2877 for more information.
Sourcepub fn tcp_keepalive(self, tcp_keepalive: Option<Duration>) -> Self
pub fn tcp_keepalive(self, tcp_keepalive: Option<Duration>) -> Self
Set whether TCP keepalive messages are enabled on accepted connections.
If None is specified, keepalive is disabled, otherwise the duration
specified will be the time to remain idle before sending TCP keepalive
probes.
Default is no keepalive (None)
Sourcepub fn tcp_nodelay(self, enabled: bool) -> Self
pub fn tcp_nodelay(self, enabled: bool) -> Self
Set the value of TCP_NODELAY option for accepted connections. Enabled by default.
Sourcepub fn http2_max_header_list_size(self, max: impl Into<Option<u32>>) -> Self
pub fn http2_max_header_list_size(self, max: impl Into<Option<u32>>) -> Self
Sets the max size of received header frames.
This will default to whatever the default in hyper is. As of v1.4.1, it is 16 KiB.
Sourcepub fn max_frame_size(self, frame_size: impl Into<Option<u32>>) -> Self
pub fn max_frame_size(self, frame_size: impl Into<Option<u32>>) -> Self
Sets the maximum frame size to use for HTTP2.
Passing None will do nothing.
If not set, will default from underlying transport.
Sourcepub fn http1_header_read_timeout(self, timeout: Option<Duration>) -> Self
pub fn http1_header_read_timeout(self, timeout: Option<Duration>) -> Self
Sets a timeout for receiving the complete header block of an HTTP/1 request.
If a client does not transmit its entire header block within this
duration the connection is closed. This is the defense against
slowloris-style attacks, where clients hold sockets open
indefinitely by sending partial requests. Pass None to disable
the timeout.
Has no effect on HTTP/2 connections, whose liveness is covered by
Config::http2_keepalive_interval.
Default is 30 seconds, matching hyper.
Sourcepub fn accept_http1(self, accept_http1: bool) -> Self
pub fn accept_http1(self, accept_http1: bool) -> Self
Allow this accepting http1 requests.
When false, plain-text connections are served in HTTP/2-only
(prior knowledge) mode: the protocol sniff is skipped and anything
that is not an HTTP/2 preface is rejected at the transport level.
TLS connections additionally stop advertising http/1.1 via ALPN.
hyper’s HTTP/1 upgrade mechanism is unavailable in this mode;
HTTP/2 extended CONNECT is unaffected.
Default is true.
Sourcepub fn tls_handshake_timeout(self, timeout: Duration) -> Self
pub fn tls_handshake_timeout(self, timeout: Duration) -> Self
Sets the timeout for TLS handshakes on incoming connections.
Connections that do not complete the TLS handshake within this duration are dropped.
Default is 5 seconds.
Sourcepub fn max_pending_connections(self, max: usize) -> Self
pub fn max_pending_connections(self, max: usize) -> Self
Sets the maximum number of pending TLS handshakes.
When this limit is reached, new incoming connections are dropped until existing handshakes complete or time out.
Default is 4096.