pub struct Http1Options { /* private fields */ }Expand description
Configuration options for the HTTP/1.x connection handler.
Use the builder-style methods to customise behaviour, then pass the finished
value to Http1::new.
§Examples
let options = Http1Options::new()
.max_header_size(8192)
.send_date_header(false)
.header_read_timeout(Some(std::time::Duration::from_secs(10)));Implementations§
Source§impl Http1Options
impl Http1Options
Sourcepub fn new() -> Self
Available on crate feature h1 only.
pub fn new() -> Self
h1 only.Creates a new Http1Options with the following defaults:
| Option | Default |
|---|---|
max_header_size | 16 384 bytes |
max_header_count | 128 |
send_date_header | true |
header_read_timeout | 30 seconds |
send_continue_response | true |
enable_early_hints | false |
enable_vectored_write | true |
Sourcepub fn max_header_size(self, size: usize) -> Self
Available on crate feature h1 only.
pub fn max_header_size(self, size: usize) -> Self
h1 only.Sets the maximum number of bytes that may be read while parsing the request head (status line + headers).
Requests whose head exceeds this limit are rejected with an
InvalidData I/O error. Defaults to 16 384 bytes.
Sourcepub fn max_header_count(self, count: usize) -> Self
Available on crate feature h1 only.
pub fn max_header_count(self, count: usize) -> Self
h1 only.Sets the maximum number of headers that will be parsed per request.
Headers beyond this count are silently ignored by the underlying
httparse parser. Defaults to 128.
Sourcepub fn send_date_header(self, send: bool) -> Self
Available on crate feature h1 only.
pub fn send_date_header(self, send: bool) -> Self
h1 only.Controls whether a Date header is automatically added to every
response.
The value is cached and refreshed at most once per second.
Defaults to true.
Sourcepub fn enable_vectored_write(self, enable: bool) -> Self
Available on crate feature h1 only.
pub fn enable_vectored_write(self, enable: bool) -> Self
h1 only.Controls whether vectored I/O (write_vectored) is used when writing
responses.
When the underlying stream does not support vectored writes the
implementation falls back to a flattened write regardless of this
setting. Defaults to true.
Sourcepub fn header_read_timeout(self, timeout: Option<Duration>) -> Self
Available on crate feature h1 only.
pub fn header_read_timeout(self, timeout: Option<Duration>) -> Self
h1 only.Sets the timeout for reading the complete request head.
If the client does not send a full set of request headers within this
duration the connection is closed with a 408 Request Timeout response.
Pass None to disable the timeout entirely. Defaults to 30 seconds.
Sourcepub fn send_continue_response(self, send: bool) -> Self
Available on crate feature h1 only.
pub fn send_continue_response(self, send: bool) -> Self
h1 only.Controls whether a 100 Continue interim response is sent when the
request contains an Expect: 100-continue header.
Defaults to true.
Sourcepub fn enable_early_hints(self, enable: bool) -> Self
Available on crate feature h1 only.
pub fn enable_early_hints(self, enable: bool) -> Self
h1 only.Controls whether 103 Early Hints responses can be sent before the
final response.
When enabled, an EarlyHints handle is inserted into each request’s
extensions so that the handler can push early hint headers to the client.
Defaults to false.
Trait Implementations§
Source§impl Clone for Http1Options
Available on crate feature h1 only.
impl Clone for Http1Options
h1 only.Source§fn clone(&self) -> Http1Options
fn clone(&self) -> Http1Options
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Http1Options
Available on crate feature h1 only.
impl Debug for Http1Options
h1 only.