This module defines the basic service providers that handle requests and generate responses. The service providers can be used with both the reactive and the event-based daemon encapsulations.
|: string option||;||(*||The preferred name of the host. This can be a DNS name or an IP address.||*)|
|: int option||;||(*||The preferred port of the host||*)|
|: (string * int) list||;||(*||Names and ports that match this host definition, for
name-based virtual hosting. The name ||*)|
|: (Unix.inet_addr * int) list||;||(*||IP addresses and ports that also match this host definition, for
IP-based virtual hosting. The address ||*)|
For name- and IP-based virtual hosting this record describes the individual host. An incoming request matches this host if:
Hostheader is mentioned in
server_names, or if
server_pref_name is set, the name of the host is set to this string for
further processing (esp.
cgi_server_name). If not set, the name of the
host is set to the name corresponding to the matching entry of
server_addresses, or if this does not succeed, to the real IP address.
server_pref_port is set, the port of the host is set to this string for
further processing (esp.
cgi_server_port). If not set, the port of the
host is set to the port corresponding to the matching entry of
server_addresses, or if this does not succeed, to the real port number.
host record that matches any request.
can be used to specify preferred names.
Describes that services are bound to URI prefixes. The strings are URI paths (without URI escaping). For an incoming request URI, the longest matching prefix is selected, and the corresponding service is carried out.
If the URI path in the list ends with a slash, it can only be selected if the incoming request URI also includes the slash.
If the URI path in the list does not end with a slash, it can only be selected if the incoming request URI is exactly identical, or continues the path with a slash.
Configures URI distribution. The incoming request URI is normalized before being matched, and the request is rewritten to the normalized URI.
If the path starts with
.. after normalization, the request is rejected.
The request is only accepted if listed (for
`Limit), or if not listed
Add-on features for file services:
`Enable_gzip: Deprecated. Same as
`Enable_cooked_compression: Modifies the way compressed files are handled. Normally it is required that one accesses the compressed file (with suffix such as "gz") directly to get it in compressed form. If this option is enabled, though, the server also compresses the base file (without suffix such as "gz"), but only if the base file is accompanied by a compressed version (with suffix). E.g. if there is "foo" and "foo.gz", this enables that the accesses to "foo" can make use of compression.
`Enable_index_file: If enabled, accesses to directories are redirected to index files. The possible file names are given in the string list. E.g.
`Enable_index_file ["index.html"; "index.htm"]. It is redirected to these files, so these can be handled by different services if neccessary.
`Enable_listings: If enabled, directory listings are generated by calling the argument function. The
PATH_TRANSLATEDproperty of the environment contains the absolute name of the directory to list. The
PATH_INFOproperty is the corresponding URI path.
`Override_compression_suffixes l: Tags the file suffixes in
las compression schemes. A pair
(suffix,ce)sets that the
suffixmeans the content encoding
ce. Knowing this is important for determining the media type of the file.
|: string||;||(*||The document root for this file service||*)|
|: string||;||(*||The URI prefix corresponding to the document root. Escapes are not allowed||*)|
|: (string * string) list||;||(*||Maps the file suffixes (after the dot) to media types||*)|
|: string||;||(*||The media type to use if suffix mapping fails||*)|
|: file_option list||;||(*||Further options for files||*)|
Describes a file service
Translates an URI path to a file name. Raises
Not_found if not
possible. It is not checked whether the resulting file exists.
This function removes a trailing slash of the translated path, if any, and if resulting from appending the path info component. Trailing slashes must not be used to deduce that directories are accessed.
Simple listing generator for
hide: An optional list of Str regular expressions. File names matching one
of the regexps are hidden in the listing. Defaults to hiding files starting with
a dot, and files ending in a tilde character. (Changed in Ocamlnet-3.3:
hide uses now Str regexps, and no longer PCRE regexps.)
The way the
Netcgi_types.cgi_activation object is created. For typical
usage, just take:
`Std_activation_unbuffered: Creates a
Netcgi.std_activationwithout output buffer (type
`Direct "") and memory-based argument processing
`Std_activation_buffered: Creates a
Netcgi.std_activationwith a transactions buffer in memory, and memory-based argument processing
`Std_activation_tempfile: Creates a
Netcgi.std_activationwith a file as transactions buffer, and memory-based argument processing
The following option is provided for detailed control:
`Std_activation opt: Creates a
Netcgi.std_activationwith the given options
|: Nethttpd_types.extended_environment -> 'a -> unit||;||(*||A dynamic service is carried out by calling this function with the environment
and the CGI activation. The function can use all CGI features, including
setting the ||*)|
|: Nethttpd_types.extended_environment -> 'a||;||(*||The way the ||*)|
|: string option||;||(*||The URI prefix corresponding to this service. This is only used to
|: string -> string||;||(*||The function computing ||*)|
|: bool||;||(*||Whether to pass requests with |
The other condition fields
Access control by host:
`Allow: Only the listed hosts are allowed; all other are denied
`Deny: The listed hosts are denied; all other are allowed
Reads a text file with two columns where the left column is the
media type and the right column the corresponding suffix.
Returns the contents as pairs