Golux RFC Project Page - The latest version of the Internet draft for
a CGI specification. It expired before being accepted as an RFC.
CGI Programming with Perl - The best single source of information is
this book from O'Reilly. Although a CGI can be written in any language,
perl is a common language and serves to illustrate the concepts easily.
CGI.pm - a Perl5 CGI Library - Lincoln Stein's CGI.pm, the popular
perl module used in the vast majority of perl CGI's.
STDIN is used only to pass form input sent with http "PUSH" requests, see
CGI Command
Script Input for details.
All other information and form input sent with http GET requests are
passed in environment variables. See CGI environment
variables for a description of what each environment variable is used for.
NCSA originally provided some examples to demonstrate various input cases here. Unfortunately
their site seemed to be broken on the day I needed to experiment with it, so I
recreated simlar test cases and a CGI to show the input. You can see the source.
In particular, note STDIN, arguments, and environment variables PATH_INFO, and
QUERY_STRING.
Clicking the submit button will send an form request with extra path
information of /foo using the POST method, with a multiline text area,a nd
with enctype set to multipart/form-data.
The following test cases demonstrate how different headers change the behavior
of the browser. Content-type headers are also transmitted with regular web pages
and other files served by a web server. The header transmitted by the web server
depends on its configuration and is typically based on the file extention. With
a CGI we choose the Content-type header.
This CGI returns the headers on the right with the value of content type
set by the ISINDEX query and then followed by the binary file specified in
the extra path info. Note that we lie about the content-type in the second
case.
/tn110/ctype.cgi/sample.doc?msword
/tn110/ctype.cgi/sample.xls?msword
View
source.
This CGI returns just the header on the right with the location value
extracted from the extra path info.Note that the ? seperating the qurey is
writen in hex as %3F so that the browser will pass is back as part of the
extra path.
/tn110/link.cgi/http://www.google.com/ search%3Fq=porsche View
source.
This CGI returns the header on the right with the expiration set to
now + five minutes. A compliant web browser will expire this page from its
cache by this time. /tn110/exp-sample.cgi/ View
source.
Note - The Cache-Control: no-cache response header tells
the client and all intermediary caches not to cache this web page.
Unfortunately this header was not defined until HTTP/1.1, so it will not work
with a HTTP/1.0 browser.
The Pragma: no-cache header was not originally intended to be a
response header, but some browsers, under certain conditions treat it like a
Cache-Control: no-cache header. It is included only as an
attempt to stop caching on HTTP/1.0, but should not be considered reliable.
See the HTTP/1.1 specification 14.32
and 14.9
for more details. For a more sophisticated caching test see: Procata Web Caching Tests
This CGI returns the headers on the right. The nph prefix (non-parsed
headers) of the CGI causes the web server to suspend all other headers and
not to buffer the output of the CGI. /tn110/nph-sample.cgi/ View
source.
HTTP/1.0 200 OK
Apache/1.3.27 (Unix)
Content-type: text/plain