Ocamlnet 3 Reference Manual : Netcgi_common.cgi

# Class Netcgi_common.cgi

    class cgi : cgi_environment -> output_type -> request_method -> cgi_argument list -> object .. end

`cgi env op meth args` constructs `Netcgi.cgi` objects. The environment `#out_channel` is wrapped into a transactional channel or a discarding channel according to `op` (``Direct` or ``Transactional`) and `request_method` (``HEAD` requests must only return a header). For standard cases, when POST and PUT arguments are available through a `Netchannels.in_obj_channel`, we recommend you use `Netcgi_common.cgi_with_args` that will parse the arguments for you and check preconditions.

Remark: You may think that the argument `meth` is superfluous as it can be deduced from `env#cgi_request_method`. While it is true for ``DELETE`, ``GET`, ``HEAD` and ``POST`, the ``PUT` takes a `Netcgi_common.cgi_argument` parameter. Setting correctly this parameter and decoding `env#cgi_request_method` is done for you by `Netcgi_common.cgi_with_args`.

    method argument : string -> cgi_argument

    method argument_value : ?default:string -> string -> string

    method argument_exists : string -> bool

    method multiple_argument : string -> cgi_argument list

    method arguments : cgi_argument list

    method environment : cgi_environment

    method request_method : request_method

    method finalize : unit -> unit

    method url : ?protocol:Nethttp.protocol ->
           ?with_authority:other_url_spec ->
           ?with_script_name:other_url_spec ->
           ?with_path_info:other_url_spec ->
           ?with_query_string:query_string_spec -> unit -> string

The following environment properties must be available for this method to work properly (please make sure your connector provides them; the CGI spec make them compulsory anyway):

- `cgi_server_name`
- `cgi_server_port`
- `cgi_script_name`
- `cgi_path_info`

    method set_header : ?status:Nethttp.http_status ->
           ?content_type:string ->
           ?content_length:int ->
           ?set_cookie:Nethttp.cookie list ->
           ?set_cookies:Cookie.t list ->
           ?cache:cache_control ->
           ?filename:string ->
           ?language:string ->
           ?script_type:string ->
           ?style_type:string -> ?fields:(string * string list) list -> unit -> unit

    method set_redirection_header : ?set_cookies:Cookie.t list ->
           ?fields:(string * string list) list -> string -> unit

    method output : Netchannels.trans_out_obj_channel

Deprecated.Use `#out_channel` instead.

    method out_channel : Netchannels.trans_out_obj_channel

    method at_exit : (unit -> unit) -> unit