pub struct HttpServer<S, const HEADER_LIMIT: usize = DEFAULT_HEADER_LIMIT, const READ_BUF_LIMIT: usize = DEFAULT_READ_BUF_LIMIT, const WRITE_BUF_LIMIT: usize = DEFAULT_WRITE_BUF_LIMIT> { /* private fields */ }
Expand description
multi protocol handling http server
Implementations§
Source§impl<S, const HEADER_LIMIT: usize, const READ_BUF_LIMIT: usize, const WRITE_BUF_LIMIT: usize> HttpServer<S, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT>
impl<S, const HEADER_LIMIT: usize, const READ_BUF_LIMIT: usize, const WRITE_BUF_LIMIT: usize> HttpServer<S, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT>
Sourcepub fn server_threads(self, num: usize) -> Self
pub fn server_threads(self, num: usize) -> Self
Set number of threads dedicated to accepting connections.
Default set to 1.
§Panics:
When receive 0 as number of server thread.
Sourcepub fn worker_threads(self, num: usize) -> Self
pub fn worker_threads(self, num: usize) -> Self
Set number of workers to start.
Default set to available logical cpu as workers count.
§Panics:
When received 0 as number of worker thread.
Sourcepub fn worker_max_blocking_threads(self, num: usize) -> Self
pub fn worker_max_blocking_threads(self, num: usize) -> Self
Set max number of threads for each worker’s blocking task thread pool.
One thread pool is set up per worker; not shared across workers.
Sourcepub fn disable_signal(self) -> Self
pub fn disable_signal(self) -> Self
Disable signal listening.
tokio::signal
is used for listening and it only functions in tokio runtime 1.x.
Disabling it would enable server runs in other async runtimes.
pub fn backlog(self, num: u32) -> Self
Sourcepub fn disable_vectored_write(self) -> Self
pub fn disable_vectored_write(self) -> Self
Disable vectored write even when IO is able to perform it.
This is beneficial when dealing with small size of response body.
Sourcepub fn keep_alive_timeout(self, dur: Duration) -> Self
pub fn keep_alive_timeout(self, dur: Duration) -> Self
Change keep alive duration for Http/1 connection.
Connection kept idle for this duration would be closed.
Sourcepub fn request_head_timeout(self, dur: Duration) -> Self
pub fn request_head_timeout(self, dur: Duration) -> Self
Change request timeout for Http/1 connection.
Connection can not finish it’s request for this duration would be closed.
This timeout is also used in Http/2 connection handshake phrase.
Sourcepub fn tls_accept_timeout(self, dur: Duration) -> Self
pub fn tls_accept_timeout(self, dur: Duration) -> Self
Change tls accept timeout for Http/1 and Http/2 connection.
Connection can not finish tls handshake for this duration would be closed.
Sourcepub fn max_read_buf_size<const READ_BUF_LIMIT_2: usize>(
self,
) -> HttpServer<S, HEADER_LIMIT, READ_BUF_LIMIT_2, WRITE_BUF_LIMIT>
pub fn max_read_buf_size<const READ_BUF_LIMIT_2: usize>( self, ) -> HttpServer<S, HEADER_LIMIT, READ_BUF_LIMIT_2, WRITE_BUF_LIMIT>
Change max size for request head.
Request has a bigger head than it would be reject with error. Request body has a bigger continuous read would be force to yield.
Default to 1mb.
Sourcepub fn max_write_buf_size<const WRITE_BUF_LIMIT_2: usize>(
self,
) -> HttpServer<S, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT_2>
pub fn max_write_buf_size<const WRITE_BUF_LIMIT_2: usize>( self, ) -> HttpServer<S, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT_2>
Change max size for write buffer size.
When write buffer hit limit it would force a drain write to Io stream until it’s empty (or connection closed by error or remote peer).
Default to 408kb.
Sourcepub fn max_request_headers<const HEADER_LIMIT_2: usize>(
self,
) -> HttpServer<S, HEADER_LIMIT_2, READ_BUF_LIMIT, WRITE_BUF_LIMIT>
pub fn max_request_headers<const HEADER_LIMIT_2: usize>( self, ) -> HttpServer<S, HEADER_LIMIT_2, READ_BUF_LIMIT, WRITE_BUF_LIMIT>
Change max header fields for one request.
Default to 64.