Skip to content

Headers

[Source]

A collection of HTTP headers with case-insensitive name lookup.

Names are lowercased on storage. Use set() to replace all values for a name, or add() to append an additional value (appropriate for multi-value headers like Set-Cookie).

class ref Headers

Constructors

create

[Source]

Create an empty header collection.

new ref create()
: Headers ref^

Returns


Public Functions

set

[Source]

Set a header, removing any existing entries with the same name.

After this call, get(name) returns value and there is exactly one entry for this name.

fun ref set(
  name: String val,
  value: String val)
: None val

Parameters

Returns


add

[Source]

Add a header entry without removing existing entries with the same name.

This is appropriate for headers that can appear multiple times (e.g., Set-Cookie). Use set() when you want to replace.

fun ref add(
  name: String val,
  value: String val)
: None val

Parameters

Returns


get

[Source]

Get the first value for the given header name (case-insensitive).

Returns None if no header with that name exists.

fun box get(
  name: String val)
: (String val | None val)

Parameters

Returns


size

[Source]

Return the number of header entries.

fun box size()
: USize val

Returns


values

[Source]

Iterate over all header entries as (name, value) pairs.

fun box values()
: ArrayValues[(String val , String val), this->Array[(String val , String val)] ref] ref

Returns