Skip to content

Commit ddca616

Browse files
committed
Add some more documentation for Cohttp.Header
1 parent 8f24e8e commit ddca616

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

cohttp/header.mli

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,43 @@
1515
*
1616
*)
1717

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. *)
1821
type t
22+
23+
(** Construct a fresh, empty map of HTTP headers *)
1924
val init : unit -> t
25+
26+
(** Construct a fresh map of HTTP headers with a single key and value entry *)
2027
val init_with : string -> string -> t
28+
29+
(** Add a key and value to an existing header map *)
2130
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] *)
2235
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. *)
2339
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. *)
2443
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. *)
2550
val get : t -> string -> string option
51+
52+
(** Retrieve all of the values associated with a key *)
2653
val get_multi : t -> string -> string list
54+
2755
val iter : (string -> string list -> unit) -> t -> unit
2856
val map : (string -> string list -> string list) -> t -> t
2957
val fold : (string -> string -> 'a -> 'a) -> t -> 'a -> 'a

0 commit comments

Comments
 (0)