OxL Reference

data HttpConfig

Settings of a request. All durations are optional (none = no limit).

Example:

oxl✓ checked in CI
use std.http { Client, HttpConfig, Response }

fn main() io, net {
  // fail after 2 seconds, never follow redirects, accept bodies up to 1 MiB
  let cfg = HttpConfig{ timeout: 2s, maxRedirects: 0, maxBody: 1048576 }
  match Client.get("http://127.0.0.1:1/", cfg: cfg) {
    Response _ => print("answered")
    NetError _ => print("no server")
  }
}
Output
no server
pub(api) data HttpConfig

Since. 1.0.0-beta

Fields

pub(api) timeout: Duration? = none

Bound for the whole request: connect, TLS handshake, sending, every redirect, receiving the body.

pub(api) connectTimeout: Duration? = none

Bound for establishing one connection (TCP + TLS handshake).

pub(api) maxBody: i64 = 67108864

Largest response body accepted, in bytes (ProtocolError above it).

pub(api) maxRedirects: i64 = 5

0 = do not follow redirects.

pub(api) keepAlive: bool = true

Reuse connections (pool); false sends Connection: close.

pub(api) chunkedUpload: bool = false

Send request bodies with Transfer-Encoding: chunked instead of Content-Length.

pub(api) http2: bool = true

https: offer HTTP/2 in ALPN and use it when the server selects it (the connection is then shared by all tasks; Response.version is 2); a server that picks http/1.1 is remembered and served with HTTP/1.1. false = HTTP/1.1 only. http:// is always HTTP/1.1 here: cleartext HTTP/2 (h2c) is explicit, with Http2.connect("http://...") (D-3997).

pub(api) userAgent: str = "oxl-http/1.0"

Value of the User-Agent header when the request has none.

pub(api) ca: str = ""

https: trust anchors (PEM file or text) instead of the system roots.

pub(api) caPem: str = ""

https: trust anchors as PEM text.

pub(api) insecureSkipVerify: bool = false

https: skip certificate verification (tests only).

pub(api) verifyHostname: bool = true

https: check that the certificate names the host.

pub(api) pin: str = ""

https: hex SHA-256 of the server's leaf certificate.

pub(api) cert: str = ""

https: client certificate for mutual TLS.

pub(api) key: str = ""

https: private key file of the client certificate.

pub(api) certPem: str = ""

https: client certificate chain as PEM text.

pub(api) keyPem: str = ""

https: client private key as PEM text.

pub(api) keyPassword: str = ""

https: password of the client private key.

Defined in: std/http/http.oxl:112

See also