CGI environment variables

Before running a CGI script, Abyss Web Server sets its environment variables in conformity with the CGI/1.1 specification (as described in http://hoohoo.ncsa.uiuc.edu/cgi) and adds variables declared in the User CGI environment variables table as well as some system environment variables (namely PATH, TEMP, TMP, LD_LIBRARY_PATH, and TZ .)

The following list contains the variables documented in the CGI/1.1 specification and some variables commonly set by web servers:



In addition to these variables, all header lines received in the request are added to the environment with the prefix HTTP_ followed by the header name in upper cases. All - characters in the header name are changed to underscore _ characters. For example, User-Agent is translated to HTTP_USER_AGENT.

If the request results from an internal redirection (from an SSI document or if it is used as a custom error page for example), the environment variables of the parent request are also added and each variable name is prefixed by REDIRECT_. The parent request's status code is stored in the special variable REDIRECT_STATUS. The cookies of the parent request are also passed to the redirected request in the COOKIES environment variable.

Example 5-1. Using the redirection information in CGI scripts

If a CGI script is invoked after an internal redirection, it can retrieve some interesting information from the environment about its parent request such as:

Copyright © 2001-2003 by Aprelium Technologies