package cohttp
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=f027f48e132f214b3e27b63c99b247b150549e70bd6e27ad16da947ed392fa20
sha512=c8fbf840141faecb207af3ad7d2bfcdf8b8bced6c6ca4d5a22b6982d1be13f748fa6e3997c6d97351285cd3a30f57f20fd418b7195a735a13d48ba3bcdf8e23c
doc/cohttp/Cohttp/Header/index.html
Module Cohttp.Header
Map of HTTP header key and value(s) associated with them. Since HTTP headers can contain duplicate keys, this structure can return a list of values associated with a single key.
include Ppx_sexp_conv_lib.Sexpable.S with type t := t
val t_of_sexp : Sexplib0.Sexp.t -> tval sexp_of_t : t -> Sexplib0.Sexp.tval init : unit -> tConstruct a fresh, empty map of HTTP headers.
val is_empty : t -> boolTest whether HTTP headers are empty or not.
val init_with : string -> string -> tConstruct a fresh map of HTTP headers with a single key and value entry.
Add multiple key and value pairs to an existing header map.
Add multiple values to a key in an existing header map.
Given an optional header, either update the existing one with a key and value, or construct a fresh header with those values if the header is None.
Given a header, update it with the key and value unless the key is already present in the header.
add_opt_unless_exists h k v updates h with the key k and value v unless the key is already present in the header. If h is None then a fresh header is allocated containing the key k and the value v.
Remove a key from the header map and return a fresh header set. The original header parameter is not modified.
Replace the value of a key from the header map if it exists, otherwise it adds it to the header map. The original header parameter is not modified.
update h k f returns a map containing the same headers as h, except for the header k. Depending on the value of v where v is f (get h k), the header k is added, removed or updated. If v is None, the header is removed if it exists; otherwise, if v is Some z then k is associated to z in the resulting headers. If k was already associated in h to a value that is physically equal to z, h is returned unchanged. Similarly as for get, if the header is one of the set of headers defined to have list values, then all of the values are concatenated into a single string separated by commas and passed to f, while the return value of f is split on commas and associated to k. If it is a singleton header, then the first value is passed to f and no concatenation is performed, similarly for the return value. The original header parameters are not modified.
val mem : t -> string -> boolCheck if a key exists in the header.
val get : t -> string -> string optionRetrieve a key from a header. If the header is one of the set of headers defined to have list values, then all of the values are concatenated into a single string separated by commas and returned. If it is a singleton header, then the first value is selected and no concatenation is performed.
val get_multi : t -> string -> string listRetrieve all of the values associated with a key
val iter : (string -> string list -> unit) -> t -> unitval fold : (string -> string -> 'a -> 'a) -> t -> 'a -> 'aval of_list : (string * string) list -> tval to_list : t -> (string * string) listval to_lines : t -> string listReturn header fieds as a list of lines. Beware that each line ends with "\r\n" characters.
val to_string : t -> stringval get_media_type : t -> string optionval get_connection_close : t -> boolval get_acceptable_media_ranges :
t ->
(Accept.media_range * Accept.p list) Accept.qlistval get_acceptable_charsets : t -> Accept.charset Accept.qlistval get_acceptable_encodings : t -> Accept.encoding Accept.qlistval get_acceptable_languages : t -> Accept.language Accept.qlistval get_transfer_encoding : t -> Transfer.encodingval add_transfer_encoding : t -> Transfer.encoding -> tval add_authorization : t -> Auth.credential -> tval get_authorization : t -> Auth.credential optionval add_authorization_req : t -> Auth.challenge -> tval is_form : t -> boolPrepend user_agent to the product token already declared in the "User-Agent" field (if any).
val connection : t -> [ `Keep_alive | `Close | `Unknown of string ] optionval pp_hum : Format.formatter -> t -> unitHuman-readable output, used by the toplevel printer