WN home page

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

CGI and other Environment Variables for the WN Server


This is a list of environment variables set by WN. These variables are set automatically when a CGI program is called. They will also be set for use by  filters or server-side includes which executes files if an "Attribute=cgi" line is added to the file record of a document in the index.wn file.

D.1 Standard CGI Variables

This is a list of standard CGI/1.1 environment variables set by WN.

AUTH_TYPE

Contains the type of authentication being used to limit access to the current document. For example, "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 POST data.

GATEWAY_INTERFACE

Contains "CGI/1.1".

HTTP_ACCEPT

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

HTTP_ACCEPT_CHARSET

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

HTTP_ACCEPT_LANGUAGE

Contains the contents of any "Accept-Language:" 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 program 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 program. For example, 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. For example, the URL "http://host/dir/foo.cgi/stuff1/stuff2/stuff3" would have "wnroot/stuff1/stuff2/stuff3" in the PATH_TRANSLATED variable.

QUERY_STRING

The contents of the "query" part of an HTTP/1.1 GET request. This is whatever comes after the '?' in the URL. For example, 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 an HTML "<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 "#define 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 a RFC 931 identd(8) server on the client (if there is one and you have compiled the server with "#define RFC931_TIMEOUT" macro enabled in the config.h file).

REQUEST_METHOD

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

REMOTE_USER

If the CGI program is password protected this will contain the user name provided by the client.

SCRIPT_FILENAME

The name of the CGI program being executed and its path relative to the system root. For example, the URL "http://host/dir/foo.cgi/stuff1/stuff2/stuff3" would have "wnroot/dir/foo.cgi" in the SCRIPT_FILENAME variable.

SCRIPT_NAME

The name of the CGI program being executed and its path relative to the WN root data directory. For example, the URL "http://host/dir/foo.cgi/stuff1/stuff2/stuff3" would have "/dir/foo.cgi" in the SCRIPT_NAME variable.

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_PORT

Contains port on which server is running.

SERVER_PROTOCOL

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

SERVER_SOFTWARE

Contains "WN <version>". For example, "WN 2.0.0". 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.

D.2 WN Specific CGI Variables

The following are not standard CGI/1.1 environment variables but are provided by the WN server when CGI variables are set:

DOCUMENT_ROOT

Contains the path to your WN root data directory relative to the system root. For example, the URL "http://host/dir/foo.cgi/stuff1/stuff2/stuff3" would have "wnroot" in the DOCUMENT_ROOT variable.

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 program terminates. A CGI program 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 program terminates. A CGI program can move it or copy it.

HTTP_VIA

Contains the contents of any "Via" header supplied by the client.

HTTP_X_FORWARDED_FOR

Contains the contents of any "X-Forwarded-For" header supplied by the client.

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 program relative to the system root. For example, the URL "http://host/dir/foo.cgi/stuff1/stuff2/stuff3" would have "wnroot/dir" in the WN_DIR_PATH variable.

WN_ROOT

Deprecated. See DOCUMENT_ROOT.

D.3 WN Specific Database Variables

One further environment variable is used by WN in conjunction with external databases.

WN_KEY

WN_KEY is used in conjunction with external databases and either "Cache-Module=" or "File-Module=" directory directives. For more details on these see the chapter "WN Auxiliary Modules" in this guide.


WN version 2.5.0
Copyright © 1998-2005 John Franks <john@math.northwestern.edu>
licensed under the GNU Free Documentation License
Last modified: Sat June 18 2005
[Previous] [Next] [Up] [Top] [Search] [Index]