module Cgi:(F)CGI high level functionssig..end
exception HttpError of int
module Request:sig..end
type connection
val establish_server : ?max_conns:int ->
?max_reqs:int ->
?sockaddr:Unix.sockaddr ->
?post_max:int -> (connection -> unit) -> unitestablish_server ?max_conns ?max_reqs ?sockaddr ?post_max f
starts a server listening on the socket appropriate for CGI or
FCGI and, for each accepted connection conn, executes f
conn. The exceptions possibly raised by f are not caught
by establish_server. It is no problem that f starts a new
thread to handle the connection (and thus returns immediately).max_conns : is the maximum of connections the web server
can make to this script. By default, each connection is
processed sequentially, so the default value for max_conns
is 1. If you start processes or threads to handle
connections, it is your responsability not to accept more than
max_conns connections. The value of max_conns only serves
to inform the web server about the capabilities of the FCGI
script.max_reqs : is the maximum of requests a web server can
multiplex through a given connection. Again, if you start
processes ot threads to handle requests, it is your
responsability to limit the number of them. max_reqs is
only used to inform the web server about how many requests it
can multiplex on a given connection. Beware that if you set
max_reqs to 1 but have threads handling different requests
of a given connection, the outputs may mix-up (thus be
incorrect).sockaddr : the unix or the TCP/IP socket that the script
will use to communicate with the web server. Setting this
implies that the script uses the FCGI protocol. By default,
on uses what is appropriate for the CGI OR FCGI protocol. For
example, if your script is listening on port 8888 on a
possibly remote machine, you can use
Unix.ADDR_INET(Unix.inet_addr_any, 8888).post_max : set the maximum size for POSTed requests in
bytes. This is a security feature to prevent clients from
overrunning the server with data. The default is
Sys.max_string_length, meaning no limit (besides OCaml
ones).
For FastCGI, the environment variable FCGI_WEB_SERVER_ADDRS may be used to specify a coma separated list of IP addresses from which the web server can connect. If not set, any address is accepted.
val handle_requests : ?fork:((Request.t -> unit) -> Request.t -> unit) ->
(Request.t -> unit) -> connection -> unithandle_requests ?fork f conn listen on the connection conn
for requests. For each completed request req, it executes
fork f req.fork : the function that starts a new process or thread.
The default is to execute f and only after continue to
listen for more requests.
Exceptions thrown by f are caught (so the possible thread
executing f will not be terminated by these). The exception
Exit is caught and ignored (this is considered a valid way
of ending a script). CamlGI.Cgi.HttpError exceptions are
turned into appropriate error codes. All other exceptions
provoke a internal server error and are logged in the server
error log.
Note that the exceptions raised by fork are NOT caught.
val register_script : ?sockaddr:Unix.sockaddr -> (Request.t -> unit) -> unitregister_script f once to register their
main function f. This should be called last (nothing that
follows will be executed). The data is buffered and may not
be fully written before f ends.
This is actually a convenience function that sets up a server (with
establish_server) and processes (through handle_requests)
all connections and requests sequentially -- i.e. no
fork/thread.
class type template =object..end
exception Abort
type upload_data = {
|
upload_value : |
|
upload_filename : |
|
upload_content_type : |
cgi#upload method.class cgi :Request.t ->object..end
new cgi r creates a cgi object for the request r.
val random_sessionid : unit -> stringmodule Cgi_args:sig..end
val cHTTP_CONTINUE : intval cHTTP_SWITCHING_PROTOCOLS : intval cHTTP_PROCESSING : intval cHTTP_OK : intval cHTTP_CREATED : intval cHTTP_ACCEPTED : intval cHTTP_NON_AUTHORITATIVE : intval cHTTP_NO_CONTENT : intval cHTTP_RESET_CONTENT : intval cHTTP_PARTIAL_CONTENT : intval cHTTP_MULTI_STATUS : intval cHTTP_MULTIPLE_CHOICES : intval cHTTP_MOVED_PERMANENTLY : intval cHTTP_MOVED_TEMPORARILY : intval cHTTP_SEE_OTHER : intval cHTTP_NOT_MODIFIED : intval cHTTP_USE_PROXY : intval cHTTP_TEMPORARY_REDIRECT : intval cHTTP_BAD_REQUEST : intval cHTTP_UNAUTHORIZED : intval cHTTP_PAYMENT_REQUIRED : intval cHTTP_FORBIDDEN : intval cHTTP_NOT_FOUND : intval cHTTP_METHOD_NOT_ALLOWED : intval cHTTP_NOT_ACCEPTABLE : intval cHTTP_PROXY_AUTHENTICATION_REQUIRED : intval cHTTP_REQUEST_TIME_OUT : intval cHTTP_CONFLICT : intval cHTTP_GONE : intval cHTTP_LENGTH_REQUIRED : intval cHTTP_PRECONDITION_FAILED : intval cHTTP_REQUEST_ENTITY_TOO_LARGE : intval cHTTP_REQUEST_URI_TOO_LARGE : intval cHTTP_UNSUPPORTED_MEDIA_TYPE : intval cHTTP_RANGE_NOT_SATISFIABLE : intval cHTTP_EXPECTATION_FAILED : intval cHTTP_UNPROCESSABLE_ENTITY : intval cHTTP_LOCKED : intval cHTTP_FAILED_DEPENDENCY : intval cHTTP_INTERNAL_SERVER_ERROR : intval cHTTP_NOT_IMPLEMENTED : intval cHTTP_BAD_GATEWAY : intval cHTTP_SERVICE_UNAVAILABLE : intval cHTTP_GATEWAY_TIME_OUT : intval cHTTP_VERSION_NOT_SUPPORTED : intval cHTTP_VARIANT_ALSO_VARIES : intval cHTTP_INSUFFICIENT_STORAGE : intval cHTTP_NOT_EXTENDED : intval cDOCUMENT_FOLLOWS : intval cPARTIAL_CONTENT : intval cMULTIPLE_CHOICES : intval cMOVED : intval cREDIRECT : intval cUSE_LOCAL_COPY : intval cBAD_REQUEST : intval cAUTH_REQUIRED : intval cFORBIDDEN : intval cNOT_FOUND : intval cMETHOD_NOT_ALLOWED : intval cNOT_ACCEPTABLE : intval cLENGTH_REQUIRED : intval cPRECONDITION_FAILED : intval cSERVER_ERROR : intval cNOT_IMPLEMENTED : intval cBAD_GATEWAY : intval cVARIANT_ALSO_VARIES : int