Plasma GitLab Archive
Projects Blog Knowledge

Class type Netcgi.cgi_argument

class type cgi_argument = object .. end
Represent a key-value pair of data passed to the script (including file uploads).

method name : string
The name of the argument.
method value : string
The value of the argument, after all transfer encodings have been removed. If the value is stored in a file, the file will be loaded.
Raises
  • Argument.Oversized if the argument was discarded.
  • Failure if the object has been finalized.
method open_value_rd : unit -> Netchannels.in_obj_channel
Open the contents of the value as an input channel. This works for all kinds of arguments, regardless of their #storage and #representation.
Raises
  • Argument.Oversized if the argument was discarded.
  • Failure if the object has been finalized.
method store : [ `File of string | `Memory ]
Tells whether the argument is stored in memory (as a string) or as a file (the argument of `File being the filename).
method content_type : unit -> string * (string * Netmime_string.s_param) list
Returns the content type of the header and its parameters as a couple (hdr, params). When the header is missing, the result is ("text/plain", []). Below you will find access method for frequently used parameters.
method charset : string
The charset parameter of the content type of the header, or "" when there is no such parameter, or no header.
method filename : string option
The filename parameter found in the header of file uploads. When present, Some name is returned, and None otherwise. (This is not to be confused with the possible local file holding the data.)
method representation : [ `MIME of Netmime.mime_message | `Simple of Netmime.mime_body ]
The representation of the argument.

  • `Simple the value of the CGI argument is an unstructured string value.
  • `MIME The argument has a MIME header in addition to the value. The MIME message is read-only.

method finalize : unit -> unit
Arguments stored in temp files must be deleted when the argument is no longer used. You can call finalize to delete such files. The method does not have any effect when store = `Memory. The method never raises any exceptions. If the file no longer exists (e.g. because it was moved away) or if there are any problems deleting the file, the error will be ignored.

The finalize method is not registered in the garbage collector. You can do that, but it is usually better to call this method manually.

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