Headers¶
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).
Constructors¶
create¶
Create an empty header collection.
Returns¶
- Headers ref^
Public Functions¶
set¶
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.
Parameters¶
Returns¶
- None val
add¶
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.
Parameters¶
Returns¶
- None val
get¶
Get the value for the given header name (case-insensitive).
A known set of comma-separated list fields โ such as Connection,
Accept, Cache-Control, and the other standard request list fields โ
are treated specially: the values of all lines with this name are
combined into one value, joined by commas in the order they appeared, per
RFC 9110 ยง5.3. For every other field, the first value is returned. A field
not in the known set always returns its first value, so combine such a
field's repeated lines yourself (via values()) if you need them.
Returns None if no header with that name exists.
The combined value is safe to split on commas for simple-token list
fields like Connection. Complex list fields whose elements can contain
quoted commas (e.g. Accept) need a quoted-string-aware tokenizer to
split correctly โ combining here does not change that.
Parameters¶
- name: String val
Returns¶
size¶
Return the number of header entries.
Returns¶
- USize val
values¶
Iterate over all header entries as Header val objects.
Returns¶
- ArrayValues[Header val, this->Array[Header val] ref] ref