The first header called name (any case); found says whether there was one.
find_header :: (
headers: [] Header_Field,
name: string
) -> (value: string, found: bool)
The first header called name (any case); found says whether there was one.
Parameters
- headers: [] Header_Field
- name: string
Returns
- value: string
- found: bool
find_header :: (
headers: [] Header_Field,
id: Header_Name
) -> (value: string, found: bool)
The first header whose id is id, as the value and whether there was one. This is the quick form for well-known headers:
it compares ids, not strings. found is false when there is none and the value is then "".
Parameters
- headers: [] Header_Field
- id: Header_Name
Returns
- value: string
- found: bool
headers := Header_Field.[
.{ name = "Host", value = "example.com", id = .HOST },
.{ name = "X-Custom", value = "padded" },
];
value, found := find_header(headers, .HOST);
assert(found && value == "example.com");
_, found = find_header(headers, .CONTENT_TYPE);
assert(!found);