(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 causes parsing of
query-string and form data posted
with MIME type
application/x-www-form-urlencoded to return
an alist with u8vector keys and values.
This controls how uploaded files, as per
cgi:upload, are represented.
This is like
uploads-lazy but additionally affects all
parameters in a form with MIME type
move are specified,
move takes precedence.
This simplifies the value of form parameters with MIME type
text/plain to a string, discarding other MIME information.
It is only meaningful in conjunction with
#\; (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.
move option is specified to
each file contents element has the form:
(FILENAME MOVE LENGTH TYPE)
where filename is a string, length is an integer,
type is a “MIME type form” [[[TODO: this is really
a PITA to document piecemeal — might as well redirect the
effort towards making
(www mime-headers) public.]]],
and move is either a sub-list (from a sub-multipart part),
or, more typically the case a procedure that takes one arg to:
Send the part contents to port.
Return a u8vector of the part contents.
Discard the part contents and return
move-simple-text/plain does not apply to file
contents, even for file with MIME type
move is not specified to
cgi:init, read on.
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