Plasma GitLab Archive
Projects Blog Knowledge

Class Netcgi.std_activation


class std_activation : ?env:Netcgi_env.cgi_environment -> ?processing:string -> Netmime.mime_header -> argument_processing -> ?operating_type:operating_type -> unit -> Netcgi_types.cgi_activation
This class is an implementation of classical CGI. When the object is created, the CGI arguments are read from the input channel, and it is arranged that the generated page is printed to the output channel. If env is not explicitly passed, the stdin descriptor is used as input, and the stdout descriptor is used as output channel (conforming to the CGI standard); depending on the process environment variables, either the real CGI connector is activated, or the class falls back to a test mode where the user can interactively test the CGI application.

By passing env, the class can be configured differently, using other channels for I/O, or other sources for the CGI environment variables.

The argument processing determines how the CGI argument objects are created (and where). The default is fun _ _ -> `Memory.

The argument operating_type determines whether an additional transaction buffer is created. By default, no such buffer is created (`Direct "").

Example:

 let cgi = new std_activation() in
 let foo_arg = cgi # argument_value "foo" in
 cgi # set_header ~content_type:"text/plain"();
 cgi # output # output_string ("foo = " ^ foo_arg);
 cgi # commit_work();    (* implies "flush" *)
 

By default, the class only processes POST data encoded as "application/x-www-form-urlencoded" and "multipart/form-data". If the configuration of the environment permits it, data of other types are accepted, too, and one argument "BODY" is created containing the unparsed data.


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