Plasma GitLab Archive
Projects Blog Knowledge

Module Netcgi_fcgi

module Netcgi_fcgi: sig .. end

FastCGI connector.

Remark: This connector does not allow requests to be multiplexed (and let it know to the web server via FCGI_MPXS_CONNS=0). Multiplexing requests is seldom done by FastCGI modules and is even sometimes impossible because of bugs in them. Moreover, multiplexing is mostly useful if concurrent requests are handled by different threads while this library use a single thread to process all requests coming on a given connection. If the need is felt (speak out!), a multithreaded connector can be built on the side of this one.


class type cgi = object .. end

The usual Netcgi.cgi class with FCGI specific methods.

val run : ?config:Netcgi.config ->
?allow:(Unix.sockaddr -> bool) ->
?output_type:Netcgi.output_type ->
?arg_store:Netcgi.arg_store ->
?exn_handler:Netcgi.exn_handler ->
?socket:Unix.file_descr ->
?sockaddr:Unix.sockaddr -> ?port:int -> (cgi -> unit) -> unit

run f register the function f as a main function of the script. Each call to the script will execute f cgi. The code outside f will be executed only once (when the script is loaded into memory) which allows to cache database connections, etc.

config : Default: Netcgi.default_config
allow : Tells whether a connection from the socket is allowed. Default: Use the comma separated list given in the environment variable FCGI_WEB_SERVER_ADDRS or allow all if it does not exist.
output_type : Default: `Direct ""
arg_store : Default: `Automatic for all arguments.
exn_handler : See Netcgi.exn_handler. Default: delegate all exceptions to the default handler.
socket : is a listening socket to use. Overrides sockaddr and port.
sockaddr : tells on what socket to contact the script. If not specified, the script expects to be launched by the web server and to communicate with it through stdin. For external scripts (launched independently of the web server and possibly on a different machine), set sockaddr to the address the web server needs to connect to to talk to the script (this address must also be specified in the web server config file).
port : alternative way to specify sockaddr listening to localhost only. If you would like your FastCGI program to be accessed from a different machine, use sockaddr instead. Your application should be ready handle SIGUSR1, used to resquest a "graceful" process shutdown, and SIGTERM to request a quick shutdown.
val handle_request : Netcgi.config ->
Netcgi.output_type ->
Netcgi.arg_store ->
Netcgi.exn_handler ->
(cgi -> unit) ->
max_conns:int ->
log:(string -> unit) option -> Unix.file_descr -> Netcgi.connection_directive

handle_request config output_type arg_store eh f ~max_conns ~log fd: This is a lower-level interface that processes exactly one request arriving on the existing connection fd.

max_conns is passed to the FCGI client and indicates how many connections this server can process in parallel.

log is the error logger function or None, in which case errors are passed through to the FCGI client.

The other arguments are just like for run.

The return value indicates whether the connection can be kept open or must be closed.

val handle_connection : Netcgi.config ->
Netcgi.output_type ->
Netcgi.arg_store ->
Netcgi.exn_handler ->
(cgi -> unit) ->
max_conns:int -> one_shot:bool -> Unix.file_descr -> unit

handle_connection config output_type arg_store eh f ~max_conns ~one_shot fd: This is a lower-level interface that processes exactly one connection fd. The descriptor is closed (even on error).

max_conns is passed to the FCGI client and indicates how many connections this server can process in parallel.

one_shot: if true, only one request is processed over this connection, overriding any indication by the web server.

The other arguments are just like for run.

This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml