www.cgi.test- CGI testing
This module defines a useful procedures to test CGI script. The test actually runs the named script, with specified enviornment variable settings, and retrieve the output. Your test procedure then examine whether the output is as expected or not.
The module keeps a table of default values of enviornment variables with which the cgi script will be run. These procedures allow the programmer to get/set those default values.
Note that you can override these default values and/or pass additional environment variables for each call of cgi script. The following environment variables are set by default.
Runs a script with given enviornment, and calls proc with
one argument, an input port which is connected to the pipe of script’s
The argument script should be a list of
program name and its arguments. Each element are
x->string first to stringify.
The script is run under the enviornment given by enviornment
variable and the default test environment described above.
The environment argument must be an associative list, in which each
car) is the name of the enviornment variable and
cdr is the value. Both are passed to
If the same environment variable appears in environment and
the default test enviornment, the one in environment is used.
Additionally, if an associative list is given to the parameters
argument, a query string is built from it and passed the script.
The actual method to pass the query string depends on the value
REQUEST_METHOD environment variable in the setting.
REQUEST_METHOD is either
the query string is put in an environment variable
If it is
POST, the query string is fed to the standard
input of the script. In the latter case,
is set to
CONTENT_LENGTH are set to the length of
REQUEST_METHOD is other values,
parameters is ignored.
You can bypass this mechanism and set up enviornment variable
QUERY_STRING directly, if you wish.
A convenient wrapper of
The script, environment and parameters are passed
call-with-cgi-script as they are.
The output of the script is parsed by
First, the RFC2822 header fields are parsed by
rfc822-read-headers (see RFC822 message parsing).
Then, the reader is called with an input port which
is piped to the script’s output.
Run-cgi-script->header&body returns two values,
the list of headers (as parsed by
and the return value of reader.
This is a procedure that uses
(see Functional XML parser) as the reader
Useful when you’re testing a cgi script that produces
well-formed HTML and/or XML document.
These procedures use
(see Input utility functions) as the reader
(run-cgi-script->string-list "bbs.cgi" :environment '((REMOTE_ADDR . "188.8.131.52")) :parameters '((command . "view") (page . 1234)))