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:
PATH_INFO: The extra path information, as given in the requested URL. In fact, scripts can be accessed by their virtual path, followed by extra information at the end of this path. The extra information is sent as PATH_INFO.
PATH_TRANSLATED: The virtual-to-real mapped version of PATH_INFO.
SCRIPT_NAME: The virtual path of the script being executed.
SCRIPT_FILENAME: The real path of the script being executed.
SERVER_SOFTWARE: The web server's software identity.
SERVER_NAME: The host name or the IP address of the computer running the web server as given in the requested URL.
SERVER_PORT: The port to which the request was sent.
GATEWAY_INTERFACE: The CGI Specification version supported by the web server; always set to CGI/1.1.
SERVER_PROTOCOL: The HTTP protocol version used by the current request.
REQUEST_METHOD: The method used by the current request; usually set to GET or POST.
QUERY_STRING: The information which follows the ? character in the requested URL.
REMOTE_ADDR: The IP address of the computer that sent the request.
REMOTE_PORT: The port from which the request was sent.
CONTENT_TYPE: The MIME type of the request body; set only for POST or PUT requests.
CONTENT_LENGTH: The length in bytes of the request body; set only for POST or PUT requests.
DOCUMENT_ROOT: The absolute path of the web site files. It has the same value as Documents Path.
AUTH_TYPE: The authentication type if the client has authentiticated itself to access the script.
AUTH_USER and REMOTE_USER: The name of the user as issued by the client when authentiticating itself to access the script.
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:
REDIRECT_SCRIPT_NAME: The virtual path of the parent document.
REDIRECT_STATUS: The status code of the parent request. It is useful when writing scripts that generate custom error pages.