Skip to main content

Http2Options

Struct Http2Options 

Source
pub struct Http2Options { /* private fields */ }
Available on crate feature h2 only.
Expand description

HTTP/2 server configuration.

Build one with Http2Options::default and override individual fields with the builder methods, then hand it to Http2::new.

Unlike the framing/header limits below, the connection window settings (initial_stream_window_size and initial_connection_window_size) are advisory: a client may shrink them with its own SETTINGS, and the server honours the smaller value.

Implementations§

Source§

impl Http2Options

Source

pub fn handshake_timeout(self, handshake_timeout: Option<Duration>) -> Self

Sets the maximum time to wait for a client to send the HTTP/2 preface before aborting the connection.

Source

pub fn send_continue_response(self, send_continue_response: bool) -> Self

Sends 100 Continue responses automatically when a request has a body.

Defaults to true.

Source

pub fn send_date_header(self, send_date_header: bool) -> Self

Inserts a Date header into responses that lack one.

Defaults to true.

Source

pub fn max_concurrent_streams(self, max_concurrent_streams: u32) -> Self

Sets the maximum number of concurrent streams allowed on a connection.

Defaults to 200.

Source

pub fn initial_stream_window_size(self, initial_stream_window_size: u32) -> Self

Sets the initial per-stream flow-control window size advertised to the client. Defaults to 1_048_576.

Source

pub fn initial_connection_window_size( self, initial_connection_window_size: u32, ) -> Self

Sets the initial connection-level flow-control window size. Defaults to 1_048_576.

Source

pub fn max_frame_size(self, max_frame_size: u32) -> Self

Sets the maximum frame size the server will send or receive. Defaults to the RFC 9113 default (16_384); must not exceed 2^24 - 1.

Source

pub fn max_header_list_size(self, max_header_list_size: u32) -> Self

Sets the maximum size of an uncompressed header list the server will accept. Defaults to 16_384.

Source

pub fn enable_connect_protocol(self, enable: bool) -> Self

Sets whether to enable the Extended CONNECT protocol, allowing for example for tunneling WebSockets over HTTP/2. Defaults to false.

Source

pub fn idle_timeout(self, idle_timeout: Option<Duration>) -> Self

Sets the idle timeout: a connection that receives no frame from the peer for this long is closed gracefully with a GOAWAY (RFC 9113 Section 10.5). Defaults to None (no idle timeout).

Source

pub fn max_local_error_reset_streams(self, max: Option<usize>) -> Self

Sets the maximum number of RST_STREAM frames this endpoint sends in response to protocol errors made by the peer across the lifetime of the connection. When the peer keeps producing protocol errors past this many local resets, the connection is closed with a GOAWAY of type ENHANCE_YOUR_CALM (RFC 9113 Section 10.5.2). None disables the limit. Defaults to Some(1024).

Source

pub fn max_pending_accept_reset_streams(self, max: Option<usize>) -> Self

Sets the maximum number of streams the peer reset before this endpoint accepted them (their request was never dispatched) that may be counted at a time. When the peer keeps opening and resetting streams faster than they are consumed, the connection is closed with a GOAWAY of type ENHANCE_YOUR_CALM (RFC 9113 Section 10.5.2). None disables the limit. Defaults to Some(20).

Source

pub fn max_continuation_frames(self, max: Option<usize>) -> Self

Sets the maximum number of frames that may compose a single header field block that has not yet been terminated by END_HEADERS. A field block is opened by a HEADERS (or PUSH_PROMISE) frame without END_HEADERS and continued by CONTINUATION frames. When a peer keeps one open past this many frames, it is a CONTINUATION flood and the stream is reset with RST_STREAM PROTOCOL_ERROR.

None (the default) computes a safe bound automatically: the configured max_header_list_size divided by max_frame_size, plus a ~20% packing buffer and a fixed slack of 10 frames. This is enough for any honestly-packed header block while catching floods that never close the block.

Defaults to None.

Trait Implementations§

Source§

impl Clone for Http2Options

Source§

fn clone(&self) -> Http2Options

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Http2Options

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Http2Options

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more