module Nethttp:sig..end
These definitions can be used by both HTTP clients and servers, and by protocols in the middle, e.g. CGI.
typeprotocol_version =int * int
A pair of a major and minor version number
typeprotocol_attribute =[ `Secure_https ]
typeprotocol =[ `Http of protocol_version * protocol_attribute list
| `Other ]
The base protocol. RFC 2145 defines how to interpret major and minor numbers. In particular, we have:
`Http((0,9),_) is the ancient HTTP version 0.9`Http((1,n),_) is the HTTP protocol 1.n. It is expected that
all these versions are compatible to each other
except negotiable features.`Http((m,_),_) for m>1 is regarded as unknown protocol,
incompatible to any `Http((1,n),_)`Other is anything else (unrecognizes protocol)val string_of_protocol : protocol -> stringReturns the string representation, e.g. "HTTP/1.0". Fails for `Other
val protocol_of_string : string -> protocolParses the protocol string, e.g. "HTTP/1.0". Returns `Other
for unrecognized strings
typehttp_status =[ `Accepted
| `Bad_gateway
| `Bad_request
| `Conflict
| `Continue
| `Created
| `Expectation_failed
| `Forbidden
| `Found
| `Gateway_timeout
| `Gone
| `Http_version_not_supported
| `Internal_server_error
| `Length_required
| `Method_not_allowed
| `Moved_permanently
| `Multiple_choices
| `No_content
| `Non_authoritative
| `Not_acceptable
| `Not_found
| `Not_implemented
| `Not_modified
| `Ok
| `Partial_content
| `Payment_required
| `Precondition_failed
| `Proxy_auth_required
| `Request_entity_too_large
| `Request_timeout
| `Request_uri_too_long
| `Requested_range_not_satisfiable
| `Reset_content
| `See_other
| `Service_unavailable
| `Switching_protocols
| `Temporary_redirect
| `Unauthorized
| `Unsupported_media_type
| `Use_proxy ]
HTTP response status:
Informational (1xx):
`Continue`Switching_protocolsSuccessful (2xx):
`Ok`Created`Accepted`Non_authoritative`No_content`Reset_content`Partial_contentRedirection (3xx):
`Multiple_choices`Moved_permanently`Found`See_other`Not_modified`Use_proxy`Temporary_redirectClient error (4xx):
`Bad_request`Unauthorized`Payment_required`Forbidden`Not_found`Method_not_allowed`Not_acceptable`Proxy_auth_required`Request_timeout`Conflict`Gone`Length_required`Precondition_failed`Request_entity_too_large`Request_uri_too_long`Unsupported_media_type`Request_range_not_satisfiable`Expectation_failedServer Error (5xx):
`Internal_server_error`Not_implemented`Bad_gateway`Service_unavailable`Gateway_timeout`Http_version_not_supportedval int_of_http_status : http_status -> intReturns the integer code for a status value
val http_status_of_int : int -> http_statusReturns the status value for an integer code, or raises Not_found
val string_of_http_status : http_status -> stringReturns the informational text for a status value
val base_code : int -> intAllows to handle unknown status codes that are untranslatable by
http_status_of_int:
E.g.
let st =
try Nethttp.http_status_of_int code
with Not_found ->
Nethttp.http_status_of_int (Nethttp.base_code code)
typehttp_method =string * string
Method name, URI
typecache_control_token =[ `Extension of string * string option
| `Max_age of int
| `Max_stale of int option
| `Min_fresh of int
| `Must_revalidate
| `No_cache of string list
| `No_store
| `No_transform
| `Only_if_cached
| `Private of string list
| `Proxy_revalidate
| `Public
| `S_maxage of int ]
The cache control token for the Cache-control header
typeetag =[ `Strong of string | `Weak of string ]
Entity tags can be weak or strong
val weak_validator_match : etag -> etag -> boolWhether the tags match weakly (see RFC 2616 for definition)
val strong_validator_match : etag -> etag -> boolWhether the tags match strongly (see RFC 2616 for definition)
exception Bad_header_field of string
Raised when a header field cannot be parsed. The string argument is the name of the failing function
class type http_header = Netmime.mime_header
class type http_header_ro = Netmime.mime_header_roThe HTTP header is represented as MIME header
class type http_trailer = Netmime.mime_header
class type http_trailer_ro = Netmime.mime_header_roThe HTTP trailer is represented as MIME header
val status_of_cgi_header : http_header -> int * stringReturns the status code and the status text corresponding to the
Status header
= {
|
: |
(* | The name of the cookie | *) |
|
: |
(* | The value of the cookie. There are no restrictions on the value of the cookie | *) |
|
: |
(* | Expiration:
| *) |
|
: |
(* | Cookies are bound to a certain domain, i.e. the browser sends them only when web pages of the domain are requested:
| *) |
|
: |
(* | Cookies are also bound to certain path prefixes, i.e. the browser sends them only when web pages at the path or below are requested.
| *) |
|
: |
(* | Cookies are also bound to the type of the web server:
| *) |
These are old-style cookies, as introduced by Netscape. For
a better representation of cookies see the Nethttp.Cookie
module.
This type is kept for now (and is also not considered as deprecated),
as the access functions in the Nethttp.Header module are more
complete than those for Nethttp.Cookie.
= netscape_cookie
Compatibility name. Deprecated
val decode_query : string -> string * stringSplits the URI into a "script name" and a "query string"
val split_host_port : string -> string * int optionSplits the Host header in hostname and optional port number.
Fails on syntax error
val uripath_encode : string -> stringEncodes unsafe characters in URI paths. The slash character is not encoded. This function should only be applied to the part before '?'.
val uripath_decode : string -> stringDecodes %XX sequences in URI paths. %2F is forbidden (failure). This function should only be applied to the part before '?'.
module Cookie:sig..end
module Header:sig..end
typetransport_layer_id =int
val new_trans_id : unit -> transport_layer_idAllocates and returns a new ID
val http_trans_id : transport_layer_idIdentifies the pure HTTP transport (without SSL), with or without web proxies
val https_trans_id : transport_layer_idIdentifies anonymous HTTPS transport (i.e. no client certificates), with or without web proxies.
val spnego_trans_id : transport_layer_idIdentifies an anonymous HTTPS transport that is additionally authenticated via SPNEGO (as described in RFC 4559)
val proxy_only_trans_id : transport_layer_idIdentifies web proxy connections. Use this to e.g. send an FTP URL to a web proxy via HTTP
See also Netsys_sasl_types.SASL_MECHANISM. This is very similar,
only that
In SASL terms, HTTP authentication is normally "server first". There is only one exception: re-authentication, which is "client first".
typematch_result =[ `Accept of string * string option
| `Accept_reroute of string * string option * transport_layer_id
| `Reject
| `Reroute of string * transport_layer_id ]
module type HTTP_CLIENT_MECHANISM =sig..end