(www cgi) module provides procedures to support painlessly
writing Common Gateway Interface scripts to process interactive forms.
These scripts typically follow the following steps: initialization and
discovery, data transfer in, data transfer out.
(Re-)initialize internal data structures. This must be called before calling any other ‘cgi:foo’ procedure. For FastCGI, call this “inside the loop” (that is, for each CGI invocation).
opts are zero or more symbols that configure the module.
This controls how uploaded files, as per
cgi:upload, are represented.
#\; (semicolon), instead
of the default
#\, (comma), for splitting multiple cookies.
This is necessary, for example, if the server is configured to
provide “Netscape style” (i.e., old and deprecated) cookies.
Unrecognized options are ignored.
#t iff there is form data available.
Return a list of variable names in the form. The order of the
list is the same as that found in the form for the first occurance
of each variable and each variable appears at most once. For example,
if the form has variables ordered
a b a c d b e, then the
returned list would have order
a b c d e.
Return a list of cookie names.
Return the value of the environment variable associated with key, a symbol. Unless otherwise specified below, the return value is a (possibly massaged, possibly empty) string. The following keys are recognized:
server-software server-software-type ; part of server-software before "/" server-software-version ; part of server-software after "/" server-name server-hostname ; alias for server-name gateway-interface server-protocol server-protocol-name ; part of server-protocol before "/" server-protocol-version ; part of server-protocol after "/" server-port (integer) request-method path-info path-translated script-name query-string remote-host remote-addr auth-type authentication-type ; alias for auth-type remote-user remote-ident content-type content-length (integer, possibly 0) http-accept (list, possibly empty, of strings) http-accept-types ; alias for http-accept-types http-user-agent http-cookie
Keys not listed above result in an "unrecognized key" error.
Fetch any values associated with name found in the form data.
Return a list, even if it contains only one element. A value is
either a string, or
#f. When there are multiple values, the
order is the same as that found in the form.
Fetch only the CAR from
Convenient for when you are certain that name is associated
with only one value.
Return a list of file contents associated with name,
#f if no files are available.
Uploaded files are parsed by
parse-form (see form-2-form).
uploads-lazy option is specified to
the file contents are those directly returned by
If unspecified, the file contents are strings with the object property
#:guile-www-cgi whose value is an alist with the following keys:
identical to name (sanity check)
original/suggested filename for this bunch of bits
something like "image/jpeg"
the MIME headers before parsing
Note that the string’s object property and the keys are all keywords. The associated values are strings.
uploads-lazy is specified (to
cgi:uploads can only be called once per particular name.
Subsequent calls return
#f. Caller had better hang onto the
information, lest the garbage man whisk it away for good. This is
done to minimize the amount of time the file is resident in memory.
Fetch the first file associated with form var name. Can only be
called once per name, so the caller had better be sure that
there is only one file associated with name. Use
if you are unsure.
Fetch any cookie values associated with name. Return a list of
values in the order they were found in the HTTP header, which should
be the order of most specific to least specific path associated with
the cookie. If no cookies are associated with name, return
Fetch the first cookie value associated with name.
cgi:values, when a name occurs more than once, its associated
values are collated, thus losing information about the relative order of
different and intermingled names. For this, you can use
to access the uncollated (albeit ordered) form data.
Fetch the list of
(name . value), in the same order as found
in the form data. A name may appear more than once. A value is
either a string, or