|
15 | 15 | * |
16 | 16 | *) |
17 | 17 |
|
| 18 | +(** Map of HTTP header key and value(s) associated with them. Since HTTP |
| 19 | + headers can contain duplicate keys, this structure can return a list |
| 20 | + of values associated with a single key. *) |
18 | 21 | type t |
| 22 | + |
| 23 | +(** Construct a fresh, empty map of HTTP headers *) |
19 | 24 | val init : unit -> t |
| 25 | + |
| 26 | +(** Construct a fresh map of HTTP headers with a single key and value entry *) |
20 | 27 | val init_with : string -> string -> t |
| 28 | + |
| 29 | +(** Add a key and value to an existing header map *) |
21 | 30 | val add : t -> string -> string -> t |
| 31 | + |
| 32 | +(** Given an optional header, either update the existing one with |
| 33 | + a key and value, or construct a fresh header with those values if |
| 34 | + the header is [None] *) |
22 | 35 | val add_opt : t option -> string -> string -> t |
| 36 | + |
| 37 | +(** Remove a key from the header map and return a fresh header set. The |
| 38 | + original header parameter is not modified. *) |
23 | 39 | val remove : t -> string -> t |
| 40 | + |
| 41 | +(** Replace a key from the header map if it exists. The original |
| 42 | + header parameter is not modified. *) |
24 | 43 | val replace : t -> string -> string -> t |
| 44 | + |
| 45 | +(** Retrieve a key from a header. If the header is one of the set of |
| 46 | + headers defined to have list values, then all of the values are |
| 47 | + concatenated into a single string separated by commas and returned. |
| 48 | + If it is a singleton header, then the first value is selected and |
| 49 | + no concatenation is performed. *) |
25 | 50 | val get : t -> string -> string option |
| 51 | + |
| 52 | +(** Retrieve all of the values associated with a key *) |
26 | 53 | val get_multi : t -> string -> string list |
| 54 | + |
27 | 55 | val iter : (string -> string list -> unit) -> t -> unit |
28 | 56 | val map : (string -> string list -> string list) -> t -> t |
29 | 57 | val fold : (string -> string -> 'a -> 'a) -> t -> 'a -> 'a |
|
0 commit comments