OxL Reference

method Response.header

The first header with this name (case-insensitive).

Example:

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

fn sample() -> Response {
  Response{
    status: 200, reason: "OK", version: "1.1",
    headers: [Header{ name: "Content-Type", value: "text/plain" }, Header{ name: "Set-Cookie", value: "a=1" }, Header{ name: "Set-Cookie", value: "b=2" }],
    body: Utf8.encode("hello"), url: "http://example.org/", reused: false, redirects: 0
  }
}

fn main() io {
  let r = sample()
  print("{r.header("content-type") ?? "-"} {r.header("etag") ?? "-"}")
}
Output
text/plain -
pub(api) fn header(name: str) -> str?

Complexity. O(h) in the number of headers.

Since. 1.0.0-beta

Parameters

NameType
namestr

Returns

str?

Effects

none declared (pure unless the body says otherwise)

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

See also