pub struct Http1Options { /* private fields */ }h1 only.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
pub fn new() -> Self
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
pub fn max_header_size(self, size: usize) -> Self
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
pub fn max_header_count(self, count: usize) -> Self
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
pub fn send_date_header(self, send: bool) -> Self
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
pub fn enable_vectored_write(self, enable: bool) -> Self
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
pub fn header_read_timeout(self, timeout: Option<Duration>) -> Self
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
pub fn send_continue_response(self, send: bool) -> Self
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
pub fn enable_early_hints(self, enable: bool) -> Self
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
impl Clone for Http1Options
Source§fn clone(&self) -> Http1Options
fn clone(&self) -> Http1Options
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more