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.add_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.
def_some n o hs is hs with n defined to v if o is Some v and hs otherwise.
def_if_undef n v hs is hs with n defined to v if n is not defined in hs.
add_value n v hs appends v to the multi-valued header n in hs.
add_set_cookie c hs adds a set_cookie header with value c. This appends to set_cookie, see t.
override hs ~by are the headers of both hs and by with those of by taking over.
val pp : Stdlib.Format.formatter -> t -> unitpp ppf hs prints an unspecified representation of hs on ppf.
val encode_http11 : t -> stringencode_http11 hs is hs as sequence of crlf terminated HTTP/1.1 headers. This correctly handles the Headers.set_cookie header.
find n hs is the value of n in hs (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' is like find. Except if the header is absent it returns an error message of the form "%s: No such header".
get n hs is like find but raises Invalid_argument if n is not defined in hs.
fold f m acc folds f over the bindings of hs starting with acc.
val request_body_length :
t ->
([ `Length of int | `Chunked ], string) Stdlib.resultrequest_body_length hs 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 hs.
decode_host scheme r 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 hs body are the headers of hs prepared for output 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 add_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.
val decode_http11_header : string -> (Name.t * string, string) Stdlib.resultdecode_http11_header s decodes a header from s.
val pp_header : Stdlib.Format.formatter -> (Name.t * string) -> unitpp_header formats a header for inspection with HTTP/1.1 syntax.
val is_empty : t -> boolis_empty hs is true iff hs is has no definition.
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 set_cookie : Name.tval transfer_encoding : Name.tval user_agent : Name.tval www_authenticate : Name.t