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 ->
(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 -> 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 -> (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 -> 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 -> (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 -> string list -> stringval set_accept_encoding : #Nethttp.http_header -> (string * (string * string) list) list -> unitAccept-encoding headerval get_accept_language : #Nethttp.http_header -> (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 -> 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 -> floatAge header as numberval set_age : #Nethttp.http_header -> float -> unitAge headerval get_allow : #Nethttp.http_header -> 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 headerval get_authorization : #Nethttp.http_header -> 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.
val set_authorization : #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 -> 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 -> 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 -> string listContent-encoding header as list of tokens.
All present Content-encoding headers are merged. The function 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 -> string listContent-language header as list of tokens.
All present Content-language headers are merged. The function 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 -> int64Content-length header as number. If the number is too big for
int64, the exception Bad_header_field "Content-length" will be raised.
Raises Not_found when the header is missing.val set_content_length : #Nethttp.http_header -> int64 -> unitContent-length headerval get_content_location : #Nethttp.http_header -> stringContent-location header as string. Raises Not_found when the
header is missing.val set_content_location : #Nethttp.http_header -> string -> unitContent-location headerval get_content_md5 : #Nethttp.http_header -> stringContent-MD5 header as string. The Base64 encoding has not been
touched. Raises Not_found when the header is missing.val set_content_md5 : #Nethttp.http_header -> string -> unitContent-MD5 headerval get_content_range : #Nethttp.http_header -> [ `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.
Raises 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 -> string * (string * string) listContent-type header as pair (media_type, params).
Raises 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 -> floatDate header as number (seconds since the Epoch).
Raises Not_found when the header is missing.val set_date : #Nethttp.http_header -> float -> unitDate headerval get_etag : #Nethttp.http_header -> Nethttp.etagEtag header.
Raises Not_found when the header is missing.val set_etag : #Nethttp.http_header -> Nethttp.etag -> unitEtag headerval get_expect : #Nethttp.http_header ->
(string * string option * (string * string) list) listExpect header as list of triples (token,value,params).
All present Expect headers are merged. The function 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 -> floatExpires header as number (seconds since the Epoch).
Raises Not_found when the header is missing.val set_expires : #Nethttp.http_header -> float -> unitExpires headerval get_from : #Nethttp.http_header -> stringFrom header as string.
Raises Not_found when the header is missing.val set_from : #Nethttp.http_header -> string -> unitFrom headerval get_host : #Nethttp.http_header -> string * int optionHost header as pair (host,port).
Raises Not_found when the header is missing.val set_host : #Nethttp.http_header -> string * int option -> unitHost headerval get_if_match : #Nethttp.http_header -> Nethttp.etag list optionIf-match header. The value None means "*".
Raises 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 -> floatIf-modified-since header as number (seconds since the Epoch).
Raises 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 -> Nethttp.etag list optionIf-none-match header. The value None means "*".
Raises 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 -> [ `Date of float | `Etag of Nethttp.etag ]If-range header.
Raises 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 -> floatIf-unmodified-since header as number (seconds since the Epoch).
Raises 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 -> floatLast-modified header as number (seconds since the Epoch).
Raises Not_found when the header is missing.val set_last_modified : #Nethttp.http_header -> float -> unitLast-modified headerval get_location : #Nethttp.http_header -> stringLocation header as string.
Raises Not_found when the header is missing.val set_location : #Nethttp.http_header -> string -> unitLocation headerval get_max_forwards : #Nethttp.http_header -> intMax-forwards header as number.
Raises Not_found when the header is missing.val set_max_forwards : #Nethttp.http_header -> int -> unitMax-forwards headerval get_pragma : #Nethttp.http_header -> (string * string option) listPragma header as list of pairs (token,value).
All present Pragma headers are merged. The function 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 -> (string * (string * string) list) listProxy-authenticate header as list of challenges
(auth_scheme,auth_params).
All present Proxy-authenticate headers are merged. The function raises Not_found
when there is no Proxy-authenticate header.
val set_proxy_authenticate : #Nethttp.http_header -> (string * (string * string) list) list -> unitProxy-authenticate headerval get_proxy_authorization : #Nethttp.http_header -> string * (string * string) listProxy-authorization header as pair
(auth_scheme,auth_params).Raises 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.
val set_proxy_authorization : #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 -> [ `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).
Raises 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 -> stringReferer header as string.
Raises Not_found when the header is missing.val get_referrer : #Nethttp.http_header -> stringval set_referer : #Nethttp.http_header -> string -> unitReferer headerval set_referrer : #Nethttp.http_header -> string -> unitval get_retry_after : #Nethttp.http_header -> [ `Date of float | `Seconds of int ]Retry-after header.
Raises 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 -> stringServer header as uninterpreted string (including comments).
Raises Not_found when the header is missing.val set_server : #Nethttp.http_header -> string -> unitServer headerval get_te : #Nethttp.http_header ->
(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. The function 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 -> 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. The function 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 -> (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. The function 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 -> 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. The function 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 -> stringUser-agent header as uninterpreted string (including comments).
Raises Not_found if the header is missing.val set_user_agent : #Nethttp.http_header -> string -> unitUser-agent headerval get_vary : #Nethttp.http_header -> [ `Fields of string list | `Star ]Vary header.
Raises 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 -> (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 headerval get_cookie : #Nethttp.http_header -> (string * string) listval set_cookie : #Nethttp.http_header -> (string * string) list -> unitCookie header. Note: This does not set cookies in the client, use
set_set_cookie instead!val set_set_cookie : #Nethttp.http_header -> Nethttp.cookie list -> unitSet-Cookie header