Http.HeadersHeaders.
A datatype to handle the quirky HTTP headers.
module Name : sig ... endHeader names.
The type for HTTP headers. Maps header names to string values such that for:
','. Use Headers.values_of_string on the string.set_cookie header, must be treated specially since it can be repeated but does not follow the syntax of multi-valued headers. The values are stored in the string separated by '\x00' values. Use Headers.append_set_cookie and Headers.values_of_set_cookie_value to handle the field. Encoders must write the cookies in separate set_cookie headers.val empty : tempty has no header definition.
define_if_some n o headers is headers with n defined to v if o is Some v and headers otherwise.
define_if_undefined n v headers is headers with n defined to v if n is not defined in headers.
append_value n v headers appends v to the multi-valued header n in headers.
append_set_cookie c headers adds a set_cookie header with value c. This appends to set_cookie, see t.
override headers ~by are the headers of both headers and by with those of by taking over.
find n headers is the value of n in headers (if any). If lowervalue is true (defaults to false) the US-ASCII uppercase letter are mapped on lowercase.
If n is a multi-valued header use values_of_string on the result. If n is set_cookie you must use values_of_set_cookie_value.
find_or_error is like find. Except if the header is absent it returns an error message of the form "%s: No such header".
get n headers is like find but raises Invalid_argument if n is not defined in headers.
fold f headers acc folds f over the bindings of headers starting with acc.
TODO Try to get rid of this.
val request_body_length :
t ->
([ `Length of int | `Chunked ], string) Stdlib.resultrequest_body_length headers determines the message body length of a request (the rules for responses is a bit different) as per HTTP/1.1 specification, by looking at the content_type and transfer_encoding in headers.
decode_host scheme headers decodes the host header into a hostname and a port number. If no port number is found in the header one is derived from scheme with Scheme.tcp_port. Errors if the header is missing or on decoding errors.
for_connector headers body are the headers of headers prepared for output by a connector that will write a request or response with body body. It performs the logic described in the service responses and client requests conventions.
values_of_set_cookie_value v decodes v as stored in by append_set_cookie in the t type to a list of cookies.
values_of_string s splits the string s at ',' (or sep if specified) characters and trims the resulting strings from optional whitespace, and lowercases the result if lowercase is true.
Note that by definition the result is never the empty list, the function returns [""] on "".
values_to_string vs is String.concat "," vs but raise Invalid_argument if vs is []. TODO why ?
value_is_token s is true iff s in an HTTP a token.
value_trim_ows trims starting and ending optional whitespace (OWS).
val header_of_string : string -> (Name.t * string, string) Stdlib.resultheader_of_string s parses a header from string s assumed to be in the form name: value.
val is_empty : t -> boolis_empty headers is true iff headers is has no definition.
equal tests sets of headers for equality. Header values are tested using binary equality, for multi-valued headers and append_set_cookie order matters.
val pp : Stdlib.Format.formatter -> t -> unitpp ppf headers prints an unspecified representation of headers on ppf.
val accept_charset : Name.tval accept_encoding : Name.tval accept_language : Name.tval accept_ranges : Name.tval authorization : Name.tval cache_control : Name.tval connection : Name.tval content_disposition : Name.tval content_encoding : Name.tval content_language : Name.tval content_length : Name.tval content_location : Name.tval content_range : Name.tval content_type : Name.tval if_modified_since : Name.tval if_none_match : Name.tval if_unmodified_since : Name.tval last_modified : Name.tval max_forwards : Name.tval proxy_authenticate : Name.tval proxy_authorization : Name.tval retry_after : Name.tval sec_fetch_site : Name.tval sec_fetch_mode : Name.tval sec_fetch_user : Name.tval sec_fetch_dest : Name.tval set_cookie : Name.tval transfer_encoding : Name.tval user_agent : Name.tval www_authenticate : Name.t