Headers #
This module defines the Headers type, which represents a collection of HTTP header name-value pairs.
Reference: https://www.rfc-editor.org/rfc/rfc9110.html#section-5
A structure for managing HTTP headers as key-value pairs.
Reference: https://www.rfc-editor.org/rfc/rfc9110.html#section-5
The underlying multimap that stores headers.
Instances For
Equations
Equations
Instances For
Equations
- Std.Http.instReprHeaders = { reprPrec := Std.Http.instReprHeaders.repr }
Equations
- Std.Http.instReprHeaders.repr x✝ prec✝ = Std.Format.bracket "{ " (Std.Format.nil ++ Std.Format.text "map" ++ Std.Format.text " := " ++ (Std.Format.nest 7 (repr x✝.map)).group) " }"
Instances For
Equations
- Std.Http.instMembershipNameHeaders = { mem := fun (headers : Std.Http.Headers) (name : Std.Http.Header.Name) => name ∈ headers.map }
Retrieves the first Header.Value for the given key.
Instances For
Retrieves all Header.Value entries for the given key.
Instances For
Like getAll, but returns none instead of requiring a membership proof.
Returns none if the header is absent.
Instances For
Retrieves the first Header.Value for the given key.
Returns none if the header is absent.
Instances For
Retrieves the last header value for the given key.
Returns none if the header is absent.
Instances For
Inserts a new key-value pair into the headers.
Instances For
Adds a header from string name and value, panicking if either is invalid.
Equations
- headers.insert! name value = headers.insert (Std.Http.Header.Name.ofString! name) (Std.Http.Header.Value.ofString! value)
Instances For
Adds a header from string name and value.
Returns none if either the header name or value is invalid.
Equations
- headers.insert? name value = do let name ← Std.Http.Header.Name.ofString? name let value ← Std.Http.Header.Value.ofString? value pure (headers.insert name value)
Instances For
Inserts a new key with an array of values.
Equations
- headers.insertMany key values = { map := headers.map.insertMany key values }
Instances For
Creates headers from a list of key-value pairs.
Equations
- Std.Http.Headers.ofList pairs = { map := Std.Internal.IndexMultiMap.ofList pairs }
Instances For
Checks if a header with the given name exists.
Instances For
Converts the headers to a list of key-value pairs (flattened). Each header with multiple values produces multiple pairs.
Instances For
Converts the headers to an array of key-value pairs (flattened). Each header with multiple values produces multiple pairs.
Instances For
Folds over all key-value pairs in the headers.
Equations
- headers.fold init f = Array.foldl (fun (acc : α) (x : Std.Http.Header.Name × Std.Http.Header.Value) => match x with | (k, v) => f acc k v) init headers.map.toArray
Instances For
Maps a function over all header values, producing new headers.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Filters and maps over header key-value pairs. Returns only the pairs for which the function returns some.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Filters header key-value pairs, keeping only those that satisfy the predicate.
Equations
Instances For
Updates all the values of a header if it exists.
Instances For
Replaces the last value for the given header name. If the header is absent, returns the headers unchanged.
Equations
- headers.replaceLast name value = { map := headers.map.replaceLast name value }
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Std.Http.Headers.instEmptyCollection = { emptyCollection := Std.Http.Headers.empty }
Equations
- Std.Http.Headers.instSingletonProdNameValue = { singleton := fun (x : Std.Http.Header.Name × Std.Http.Header.Value) => match x with | (a, b) => ∅.insert a b }
Equations
- Std.Http.Headers.instInsertProdNameValue = { insert := fun (x : Std.Http.Header.Name × Std.Http.Header.Value) (s : Std.Http.Headers) => match x with | (a, b) => s.insert a b }
Equations
- Std.Http.Headers.instUnion = { union := Std.Http.Headers.merge }
Equations
- One or more equations did not get rendered due to their size.