pub struct Http1Config<'a> { /* private fields */ }server and http1 only.Expand description
Configuration of the http1 part of the Server.
This config is created by Server::http1_config
Implementations§
Source§impl Http1Config<'_>
impl Http1Config<'_>
Sourcepub fn set_auto_date_header(&mut self, auto_date_header: bool) -> &mut Self
pub fn set_auto_date_header(&mut self, auto_date_header: bool) -> &mut Self
Set whether the date header should be included in HTTP responses.
Note that including the date header is recommended by RFC 7231.
Default is true.
Sourcepub fn set_half_close(&mut self, half_close: bool) -> &mut Self
pub fn set_half_close(&mut self, half_close: bool) -> &mut Self
Set whether HTTP/1 connections should support half-closures.
Clients can chose to shutdown their write-side while waiting
for the server to respond. Setting this to true will
prevent closing the connection immediately if read
detects an EOF in the middle of a request.
Default is false.
Sourcepub fn set_keep_alive(&mut self, keep_alive: bool) -> &mut Self
pub fn set_keep_alive(&mut self, keep_alive: bool) -> &mut Self
Enables or disables HTTP/1 keep-alive.
Default is true.
Sourcepub fn set_title_case_headers(&mut self, title_case_headers: bool) -> &mut Self
pub fn set_title_case_headers(&mut self, title_case_headers: bool) -> &mut Self
Set whether HTTP/1 connections will write header names as title case at the socket level.
Default is false.
Sourcepub fn set_ignore_invalid_headers(
&mut self,
ignore_invalid_headers: bool,
) -> &mut Self
pub fn set_ignore_invalid_headers( &mut self, ignore_invalid_headers: bool, ) -> &mut Self
Set whether HTTP/1 connections will silently ignored malformed header lines.
If this is enabled and a header line does not start with a valid header name, or does not include a colon at all, the line will be silently ignored and no error will be reported.
Default is false.
Sourcepub fn set_max_headers(&mut self, max_headers: usize) -> &mut Self
pub fn set_max_headers(&mut self, max_headers: usize) -> &mut Self
Set the maximum number of headers.
When a request is received, the parser will reserve a buffer to store headers for optimal performance.
If server receives more headers than the buffer size, it responds to the client with “431 Request Header Fields Too Large”.
Note that headers is allocated on the stack by default, which has higher performance. After setting this value, headers will be allocated in heap memory, that is, heap memory allocation will occur for each request, and there will be a performance drop of about 5%.
Default is 100.