OxL Reference

data ServerConfig

Settings of a Server.

Example:

oxl✓ checked in CI
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}")
}
Output
0 1048576
pub(api) data ServerConfig

Since. 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 Server.port()).

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: 431 above it.

pub(api) maxHeaders: i64 = 100

Most header fields in a request: 431 above it.

pub(api) maxUriBytes: i64 = 8192

Longest request target: 414 above it.

pub(api) maxBody: i64 = 8388608

Largest request body in bytes: 413 above it (for a streamed body the read that passes it fails).

pub(api) streamBodyAbove: i64 = -1

Request bodies longer than this many bytes, and chunked ones, are not read before the handler runs: Request.streamed is then true, body empty, and the handler reads the pieces with req.stream() (D-3998). -1 = always buffer.

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: 408 after it.

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 shutdown lets requests in flight finish before the connections are cut.

pub(api) followNode: bool = true

Start draining when the node does (SIGTERM/SIGINT, §2.4 step 7): the accept loop of serve then returns.

pub(api) http2: bool = true

https: offer HTTP/2 (h2) next to HTTP/1.1 in ALPN (D-3996).

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

See also