data ServerConfig
Settings of a Server.
Example:
use std.http { ServerConfig }
fn main() io {
let cfg = ServerConfig{ host: "127.0.0.1", port: 0, maxBody: 1048576, idleTimeout: 15s }
print("{cfg.port} {cfg.maxBody}")
}0 1048576
pub(api) data ServerConfigSince. 1.0.0-beta
Fields
pub(api) host: str = "127.0.0.1" | Address to listen on. |
pub(api) port: u16 = 8080 | 0 picks a free port (read it back with |
pub(api) backlog: i64 = 1024 | Length of the queue of connections waiting to be accepted. |
pub(api) maxHeaderBytes: i64 = 65536 | Largest request head (request line and headers) in bytes: |
pub(api) maxHeaders: i64 = 100 | Most header fields in a request: |
pub(api) maxUriBytes: i64 = 8192 | Longest request target: |
pub(api) maxBody: i64 = 8388608 | Largest request body in bytes: |
pub(api) streamBodyAbove: i64 = -1 | Request bodies longer than this many bytes, and chunked ones, are not read before the handler runs: |
pub(api) idleTimeout: Duration = 60s | How long a keep-alive connection may wait for the next request. |
pub(api) headerTimeout: Duration = 10s | From the first byte of a request to the end of its head: |
pub(api) bodyTimeout: Duration = 30s | From the end of the head to the end of the body. |
pub(api) writeTimeout: Duration = 30s | One write to the client. |
pub(api) maxRequestsPerConn: i64 = 1000 | Requests per connection before the server asks the client to reconnect. |
pub(api) maxMessage: i64 = 16777216 | Largest WebSocket message. |
pub(api) drainTimeout: Duration = 30s | How long |
pub(api) followNode: bool = true | Start draining when the node does (SIGTERM/SIGINT, §2.4 step 7): the accept loop of |
pub(api) http2: bool = true | https: offer HTTP/2 ( |
pub(api) h2c: bool = true | Plain TCP: accept HTTP/2 with prior knowledge (a connection that starts with the h2 preface). |
pub(api) certPem: str = "" | TLS (https): certificate chain and key, as PEM text or files. |
pub(api) keyPem: str = "" | TLS: private key as PEM text. |
pub(api) cert: str = "" | TLS: certificate chain file. |
pub(api) key: str = "" | TLS: private key file. |
pub(api) keyPassword: str = "" | TLS: password of the private key. |
Defined in: std/http/http.oxl:3747