[Previous] [Next] [Up] [Top] [Search] [Index]

Appendix D: CGI and other Environment Variables


This is a list of CGI 1.1 environment variables set by WN. These variables are set automatically when a CGI script is called. They will also be set for use by filters or server-side includes which exec files if an "Attribute=cgi" line is added to the file record of a document in the index file.
AUTH_TYPE
Contains the type of authentication being used to limit access to the current document. E.g. "Basic" or "Digest".

CONTENT_LENGTH
Contains the length of information provided by a client POST. The length is an ASCII string representing the number of bytes.

CONTENT_TYPE
Contains the content type supplied by the client with POSTed data.

GATEWAY_INTERFACE
Contains "CGI/1.1".

HTTP_ACCEPT
Contains the contents of any "Accept:" headers supplied by the client.

HTTP_ACCEPT_LANGUAGE
Contains the contents of any "Accept-Language:" headers supplied by the client.

HTTP_ACCEPT_CHARSET
Contains the contents of any "Accept-Charset:" headers supplied by the client.

HTTP_COOKIE
Contains the contents of any "Cookie:" header supplied by the client.

HTTP_FROM
Contains the contents of the "From:" header supplied by the client. This may contain the e-mail address of the client user. This is generally unreliable, as usually users choose not to supply this information. If they do give it they can choose any e-mail address they want -- there is no guarantee that this is, in fact, the real e-mail address of the client user.

HTTP_HOST
Contains the contents of the "Host:" header supplied by the client. This should contain the one of the aliases for the host on which the server is running. It should be the hostname from the URL that the client is requesting. Thus a client seeking http://www.serverhost.com:8000/foo.html should supply "www.serverhost.com" in this header. Many browsers do not do this. It is required in HTTP/1.1.

HTTP_RANGE
Contains the contents of any "Range:" header supplied by the client.

HTTP_REFERER
Contains the contents of the "Referer:" header supplied by the client. This is supposed to contain the URL of the document from which a link to this script activated.

HTTP_USER_AGENT
Contains the contents of the "User-Agent:" header supplied by the client. This is supposed to contain the name of the browser which the client is using to make this request

PATH_INFO
Extra information in the "path" of a CGI URL. More precisely everything after the actual name of the script. E.g. the URL http://host/dir/foo.cgi/stuff1/stuff2/stuff3 would have /stuff1/stuff2/stuff3 in the PATH_INFO variable.

PATH_TRANSLATED
This assumes that PATH_INFO is the path of a file relative to your WN root and provides the path relative to the system root. E.g. the URL http://host/dir/foo.cgi/stuff1/stuff2/stuff3 would have /path/to/WN_root/stuff1/stuff2/stuff3 in the PATH_TRANSLATED variable.

QUERY_STRING
The contents of the "query" part of an HTTP GET request. This is whatever comes after the '?' in the URL. E.g. the URL http://host/dir/foo.cgi/stuff1/stuff2/stuff3?dingbat would have dingbat in the QUERY_STRING variable. If the request was generated by a form this contains all the form information encoded as name1=value1&name2=value2...

REMOTE_ADDR
Contains the IP address of the client or proxy making the request.

REMOTE_HOST
Contains the hostname of the client or proxy making the request, if the server can determine it otherwise it contains the IP address. If NO_DNS_HOSTNAMES is defined in config.h before compilation then no attempt will be made to determine the hostname and REMOTE_HOST will contain the IP address. (This would reduce the load on the server).

REMOTE_IDENT
Contains the user name supplied by an RFC931 identd server on the client (if there is one and you have compiled the server with RFC931 services enabled in the config.h file.)

REMOTE_USER
If the CGI script is password protected this will contain the username provided by the client.

REQUEST_METHOD
Contains either "GET", "POST" or "PUT", depending on the "method" of the client request.

SCRIPT_NAME
The name of the CGI script being executed and its path relative to the WN root. E.g. the URL http://host/dir/foo.cgi/stuff1/stuff2/stuff3 would have /dir/foo.cgi in the SCRIPT_NAME variable

SERVER_SOFTWARE
Contains "WN ", e.g. "WN 1.12.3". Recall that version numbers of the form a.b.c with 'b' even are intended to be stable releases while 'b' odd indicates a release with new and less tested features.

SERVER_NAME
Contains the name of the "virtual host" currently being accessed, if virtual hosting is in use. Otherwise it contains the name of host on which server is running. The value of this variable will be identical to the value of HTTP_HOST if the client supports the Host header. Otherwise it will be determined by the IP address to which the request was made and the corresponding entry in the virtual hosts table.

SERVER_PROTOCOL
Contains "HTTP/0.9" or "HTTP/1.0" depending on which protocol the client is using.

SERVER_PORT
Contains port on which server is running.

The following are not CGI variables but are provided by the WN server when CGI variables are set:

HTTP_POST_FILE
Contains the path to the temporary file containing the data sent by the client via the POST method. This file is removed after the CGI script terminates. A CGI script can move it or copy it.

HTTP_PUT_FILE
Contains the path to the temporary file containing the data sent by the client via the PUT method. This file is removed after the CGI script terminates. A CGI script can move it or copy it.

URL_SCHEME
Contains "http" normally or "https" in case the server has been modified to use the secure sockets layer (SSL) protocol.

WN_DIR_PATH
Contains the path to the directory containing the script relative to the system root. E.g. the URL http://host/dir/foo.cgi/stuff1/stuff2/stuff3 would have /path/to/WN_root/dir in the WN_DIR_PATH variable.

WN_ROOT
Contains the path to your WN root relative to the system root. E.g. the URL http://host/dir/foo.cgi/stuff1/stuff2/stuff3 would have /path/to/WN_root in the WN_ROOT variable.

One further environment variable is used by WN. This is WN_KEY which is used in conjunction with external databases and either Cache-Modules or File-Modules. For more details on these see the chapter on WN Auxiliary Modules.


John Franks <john@math.nwu.edu>
[Previous] [Next] [Up] [Top] [Search] [Index]