module Header:sig..end
get_* functions generally raise Not_found when the queried header
is not present. If the syntax of the field is a comma-separated list of
multiple values, the get_* functions generally merge all headers of
the same type. The order is preserved in this case. The list [] means
that the header exists, but only with empty value. For example,
Accept: text/html
Accept: text/plain
would be returned as ["text/html",[],[]; "text/plain", [],[]]
by get_accept. The header
Accept:
would be returned as [].
The set_* functions generally produce only a single header with comma-
separated values. Existing header are overwritten/removed.
To remove a header, simply use the delete_field method of http_header.
Error behaviour: The get_* functions raise Bad_header_field
when they cannot parse a header field. The set_* functions
raise Invalid_argument when an invalid value is passed to them
(only very few functions do that). The argument of both
exceptions is the function name.
val get_accept : #Nethttp.http_header_ro ->
(string * (string * string) list * (string * string) list) listAccept header as list of triples (media_range,
media_range_params, accept_params). If there are
accept_params, the first such parameter is always "q".
All present Accept headers are merged. The function returns
[] when there is at least one Accept header, but none of
the headers has a non-empty value. The function raises
Not_found if there no such headers at all (which should be
interpreted as ["*/*",[],[] ] ).
val best_media_type : #Nethttp.http_header_ro -> string list -> string * (string * string) list
Known bug: The rule that media ranges are sorted by degree of
"specificness" is not implemented, e.g. that "text/html" is
preferred over other "text/*" when both have the same "q" value.
val set_accept : #Nethttp.http_header ->
(string * (string * string) list * (string * string) list) list -> unitAccept headerval get_accept_charset : #Nethttp.http_header_ro -> (string * (string * string) list) listAccept-charset header as list of pairs (charset,params).
The only mentioned parameter in RFC 2616 is "q".
All present Accept-charset headers are merged. The function
raises Not_found when there is no Accept-charset header
(which should be interpreted as ["*",[]] ).
val best_charset : #Nethttp.http_header_ro -> string list -> string
This function already implements the special handling of ISO-8859-1
mentioned in RFC 2616.
val set_accept_charset : #Nethttp.http_header -> (string * (string * string) list) list -> unitAccept-charset headerval get_accept_encoding : #Nethttp.http_header_ro -> (string * (string * string) list) listAccept-encoding header as list of pairs (coding,params).
The only mentioned parameter in RFC 2616 is "q". The RFC describes
compatibility problems with the "q" parameter.
All present Accept-encoding headers are merged. The function
raises Not_found when there is no Accept-encoding header
(which should be interpreted as ["identity",[]] ). The
return value [] must be interpreted as ["identity",[]] .
val best_encoding : #Nethttp.http_header_ro -> string list -> stringval set_accept_encoding : #Nethttp.http_header -> (string * (string * string) list) list -> unitAccept-encoding headerval get_accept_language : #Nethttp.http_header_ro -> (string * (string * string) list) listAccept-language header as list of pairs
(lang_range,params). The only mentioned parameter in RFC
2616 is "q".
All present Accept-language headers are merged. The function
raises Not_found when there is no Accept-language header
(which should be interpreted as ["*",[]] ).
val set_accept_language : #Nethttp.http_header -> (string * (string * string) list) list -> unitAccept-language headerval get_accept_ranges : #Nethttp.http_header_ro -> string listAccept-ranges header as list of tokens.
All present Accept-ranges headers are merged. The function
raises Not_found when there is no Accept-ranges
header. The RFC leaves it open how this is to be interpreted
in general.
val set_accept_ranges : #Nethttp.http_header -> string list -> unitAccept-ranges headerval get_age : #Nethttp.http_header_ro -> floatAge header as numberval set_age : #Nethttp.http_header -> float -> unitAge headerval get_allow : #Nethttp.http_header_ro -> string listAllow header as list of tokens.
All present Allow headers are merged. The function raises Not_found
when there is no Allow header. The RFC leaves it open how this is
to be interpreted in general.
val set_allow : #Nethttp.http_header -> string list -> unitAllow header : #Nethttp.http_header_ro -> string * (string * string) listAuthorization header as pair (auth_scheme,auth_params),
or raises Not_found if not present.
The "Basic" authentication scheme is represented specially as
("basic", [ "credentials", creds ]) where creds are the
Base64-encoded credentials.
: #Nethttp.http_header -> string * (string * string) list -> unitAuthorization header.
The "Basic" authentication scheme is represented as explained for
get_authorization.val get_cache_control : #Nethttp.http_header_ro -> Nethttp.cache_control_token listCache-control header as list of tokens.
All present Cache-control headers are merged. The function
raises Not_found when there is no Cache-control header.
val set_cache_control : #Nethttp.http_header -> Nethttp.cache_control_token list -> unitCache-control headerval get_connection : #Nethttp.http_header_ro -> string listConnection header as list of tokens.
All present Connection headers are merged. The function
raises Not_found when there is no Connection header.
The Connection header must be ignored when received from a
HTTP/1.0 client.
val set_connection : #Nethttp.http_header -> string list -> unitConnection headerval get_content_encoding : #Nethttp.http_header_ro -> string listContent-encoding header as list of tokens.
All present Content-encoding headers are merged.
Raises Not_found when there is no Content-encoding header.
val set_content_encoding : #Nethttp.http_header -> string list -> unitContent-encoding headerval get_content_language : #Nethttp.http_header_ro -> string listContent-language header as list of tokens.
All present Content-language headers are merged.
Raises Not_found when there is no Content-language header.
val set_content_language : #Nethttp.http_header -> string list -> unitContent-language headerval get_content_length : #Nethttp.http_header_ro -> int64Content-length header as number. If the number
is too big for int64, the exception Bad_header_field
"Content-length" will be raised.
Not_found when the header is missing.val set_content_length : #Nethttp.http_header -> int64 -> unitContent-length headerval get_content_location : #Nethttp.http_header_ro -> stringContent-location header as string.
Not_found when the header is missing.val set_content_location : #Nethttp.http_header -> string -> unitContent-location headerval get_content_md5 : #Nethttp.http_header_ro -> stringContent-MD5 header as string. The Base64 encoding
has not been touched.
Not_found when the header is missing.val set_content_md5 : #Nethttp.http_header -> string -> unitContent-MD5 headerval get_content_range : #Nethttp.http_header_ro ->
[ `Bytes of (int64 * int64) option * int64 option ]Content-range header as
`Bytes(byte_range_resp_spec, instance_length). The option value
None corresponds to "*" in the RFC.
Not_found when the header is missing.val set_content_range : #Nethttp.http_header ->
[ `Bytes of (int64 * int64) option * int64 option ] -> unitContent-range headerval get_content_type : #Nethttp.http_header_ro -> string * (string * string) listContent-type header as pair (media_type, params).
Not_found when the header is missing.val set_content_type : #Nethttp.http_header -> string * (string * string) list -> unitContent-type headerval get_date : #Nethttp.http_header_ro -> floatDate header as number (seconds since the Epoch).
Not_found when the header is missing.val set_date : #Nethttp.http_header -> float -> unitDate headerval get_etag : #Nethttp.http_header_ro -> Nethttp.etagEtag header.
Not_found when the header is missing.val set_etag : #Nethttp.http_header -> Nethttp.etag -> unitEtag headerval get_expect : #Nethttp.http_header_ro ->
(string * string option * (string * string) list) listExpect header as list of triples (token,value,params).
All present Expect headers are merged.
Raises Not_found when there is no Expect header.
val set_expect : #Nethttp.http_header ->
(string * string option * (string * string) list) list -> unitExpect headerval get_expires : #Nethttp.http_header_ro -> floatExpires header as number (seconds since the Epoch).
Not_found when the header is missing.val set_expires : #Nethttp.http_header -> float -> unitExpires headerval get_from : #Nethttp.http_header_ro -> stringFrom header as string.
Not_found when the header is missing.val set_from : #Nethttp.http_header -> string -> unitFrom headerval get_host : #Nethttp.http_header_ro -> string * int optionHost header as pair (host,port).
Not_found when the header is missing.val set_host : #Nethttp.http_header -> string * int option -> unitHost headerval get_if_match : #Nethttp.http_header_ro -> Nethttp.etag list optionIf-match header. The value None means "*".
Not_found when the header is missing.val set_if_match : #Nethttp.http_header -> Nethttp.etag list option -> unitIf-match headerval get_if_modified_since : #Nethttp.http_header_ro -> floatIf-modified-since header as number (seconds
since the Epoch).
Not_found when the header is missing.val set_if_modified_since : #Nethttp.http_header -> float -> unitIf-modified-since headerval get_if_none_match : #Nethttp.http_header_ro -> Nethttp.etag list optionIf-none-match header. The value None means "*".
Not_found when the header is missing.val set_if_none_match : #Nethttp.http_header -> Nethttp.etag list option -> unitIf-none-match headerval get_if_range : #Nethttp.http_header_ro -> [ `Date of float | `Etag of Nethttp.etag ]If-range header.
Not_found when the header is missing.val set_if_range : #Nethttp.http_header -> [ `Date of float | `Etag of Nethttp.etag ] -> unitIf-range headerval get_if_unmodified_since : #Nethttp.http_header_ro -> floatIf-unmodified-since header as number (seconds
since the Epoch).
Not_found when the header is missing.val set_if_unmodified_since : #Nethttp.http_header -> float -> unitIf-unmodified-since headerval get_last_modified : #Nethttp.http_header_ro -> floatLast-modified header as number (seconds since the Epoch).
Not_found when the header is missing.val set_last_modified : #Nethttp.http_header -> float -> unitLast-modified headerval get_location : #Nethttp.http_header_ro -> stringLocation header as string.
Not_found when the header is missing.val set_location : #Nethttp.http_header -> string -> unitLocation headerval get_max_forwards : #Nethttp.http_header_ro -> intMax-forwards header as number.
Not_found when the header is missing.val set_max_forwards : #Nethttp.http_header -> int -> unitMax-forwards headerval get_pragma : #Nethttp.http_header_ro -> (string * string option) listPragma header as list of pairs (token,value).
All present Pragma headers are merged.
Raises Not_found when there is no Pragma header.
val set_pragma : #Nethttp.http_header -> (string * string option) list -> unitPragma headerval get_proxy_authenticate : #Nethttp.http_header_ro -> (string * (string * string) list) listProxy-authenticate header as list of challenges
(auth_scheme,auth_params).
All present Proxy-authenticate headers are merged.
Raises Not_found when there is no Proxy-authenticate header.
val set_proxy_authenticate : #Nethttp.http_header -> (string * (string * string) list) list -> unitProxy-authenticate header : #Nethttp.http_header_ro -> string * (string * string) listProxy-authorization header as pair
(auth_scheme,auth_params).Not_found when the header is
missing.
The "Basic" authentication scheme is represented specially as
("basic", [ "credentials", creds ]) where creds are the
Base64-encoded credentials.
: #Nethttp.http_header -> string * (string * string) list -> unitProxy-authorization header
The "Basic" authentication scheme is represented as explained for
get_proxy_authorization.val get_range : #Nethttp.http_header_ro -> [ `Bytes of (int64 option * int64 option) list ]Range header as `Bytes ranges, where the list ranges
has elements of the form (Some first_pos, Some last_pos),
(Some first_pos, None) (prefix range), or (None, Some
last_pos) (suffix range).
Not_found when the header is missing.val set_range : #Nethttp.http_header ->
[ `Bytes of (int64 option * int64 option) list ] -> unitRange headerval get_referer : #Nethttp.http_header_ro -> stringReferer header as string.
Not_found when the header is missing.val get_referrer : #Nethttp.http_header_ro -> stringval set_referer : #Nethttp.http_header -> string -> unitReferer headerval set_referrer : #Nethttp.http_header -> string -> unitval get_retry_after : #Nethttp.http_header_ro -> [ `Date of float | `Seconds of int ]Retry-after header.
Not_found when the header is missing.val set_retry_after : #Nethttp.http_header -> [ `Date of float | `Seconds of int ] -> unitRetry-after headerval get_server : #Nethttp.http_header_ro -> stringServer header as uninterpreted string (including
comments).
Not_found when the header is missing.val set_server : #Nethttp.http_header -> string -> unitServer headerval get_te : #Nethttp.http_header_ro ->
(string * (string * string) list * (string * string) list) listTE header as list of triples
(te_token, te_params, accept_params).
If there are accept_params, the first such parameter is always "q".
All present TE headers are merged. The function returns [] when
there is at least one TE header, but none of the headers has a
non-empty value.
Raises Not_found if there no such headers at all.
val set_te : #Nethttp.http_header ->
(string * (string * string) list * (string * string) list) list -> unitTE headerval get_trailer : #Nethttp.http_header_ro -> string listTrailer header as list of field names.
All present Trailer headers are merged. The function returns
[] when there is at least one Trailer header, but none of
the headers has a non-empty value.
Raises Not_found if there no such headers at all.
val set_trailer : #Nethttp.http_header -> string list -> unitTrailer headerval get_transfer_encoding : #Nethttp.http_header_ro -> (string * (string * string) list) listTransfer-encoding header as list of pairs
(token, params).
All present Transfer-encoding headers are merged. The
function returns [] when there is at least one
Transfer-encoding header, but none of the headers has a
non-empty value.
Raises Not_found if there no such headers at all.
val set_transfer_encoding : #Nethttp.http_header -> (string * (string * string) list) list -> unitTransfer-encoding headerval get_upgrade : #Nethttp.http_header_ro -> string listUpgrade header as list of products.
All present Upgrade headers are merged. The function returns
[] when there is at least one Upgrade header, but none of
the headers has a non-empty value.
Raises Not_found if there no such headers at all.
val set_upgrade : #Nethttp.http_header -> string list -> unitUpgrade headerval get_user_agent : #Nethttp.http_header_ro -> stringUser-agent header as uninterpreted string
(including comments).
Not_found if the header is missing.val set_user_agent : #Nethttp.http_header -> string -> unitUser-agent headerval get_vary : #Nethttp.http_header_ro -> [ `Fields of string list | `Star ]Vary header.
Not_found if the header is missing.val set_vary : #Nethttp.http_header -> [ `Fields of string list | `Star ] -> unitVary headerval get_www_authenticate : #Nethttp.http_header_ro -> (string * (string * string) list) listWWW-Authenticate header as list of challenges
(auth_scheme,auth_params).
All present WWW-Authenticate headers are merged.
Raises Not_found if the header is missing.
val set_www_authenticate : #Nethttp.http_header -> (string * (string * string) list) list -> unitWWW-Authenticate header : #Nethttp.http_header_ro -> (string * string) list : #Nethttp.http_header_ro -> Nethttp.Cookie.t listNethttp.Cookie.t representation
(the suffix "_ct" reminds of Cookie.t).
This function also supports version 1 cookies.
Returns the empty list if there are no cookies. : #Nethttp.http_header -> (string * string) list -> unitCookie header. Note: This does not set cookies in the client,
use set_set_cookie instead! : #Nethttp.http_header_ro -> Nethttp.netscape_cookie listSet-Cookie header : #Nethttp.http_header -> Nethttp.netscape_cookie list -> unitSet-Cookie header : #Nethttp.http_header -> Nethttp.Cookie.t list -> unitSet-Cookie and Set-Cookie2 headers:
set_set_cookie_ct header cookies sets the cookies in header
using version 0 or version 1 depending on whether version 1
fields are used. For better browser compatibility, if
"Set-cookie2" (RFC 2965) is issued, then a "Set-cookie"
precedes (declaring the same cookie with a limited number of
options).