Ford & Mason Ltd
HOME
ABOUT
CONTACT
RESOURCES
ADVERTISING



donations support the development of
cronolog.org
and
refcards.com

next up previous contents index
Next: Standard input stream Up: Inputs to the Previous: Command line arguments


Environment variables

Information about the request is passed to CGI scripts by the Web server in environment variables. The method of accessing the values of environment variables depends on the language used for the CGI script. Where environment variables are irrelevant to a particular request they will either not be set, or be set to an empty string, depending on the server implementation. The following environment variables are set up by the server:

QUERY_STRING
If the URL contains a query string, this variable is set to that query string.

CONTENT_TYPE
This variable is set if data is attached to the request and passed in the standard input stream. It indicates the MIME type of that data.

CONTENT_LENGTH
If data is attached it can be read from the standard input of the script. This variable gives the length of the data.

PATH_INFO
Contains any data included in the URL, after the substring identifying the script.

PATH_TRANSLATED
Contains the information given in PATH_INFO, with the Web root directory path prepended.

GATEWAY_INTERFACE
Identifies the version of the CGI specification the server is using, in the form name/version. At the time of writing this should contain CGI/1.1.

REMOTE_ADDR
The Internet address of the host machine making the request.

REMOTE_HOST
The name of the machine making the request, if it can be determined.

REMOTE_USER
The name of the authenticated user, if the server supports user authentication and the script is protected.

AUTH_TYPE
The authentication method used (only if the script is protected).

REMOTE_IDENT
If the server and the remote machine support and are configured to use the ident protocol (RFC 931), this variable contains the name of the remote user making the request. This information is not always available and in any case cannot be relied upon, as with the previous variable.

REQUEST_METHOD
Indicates the method by which the request was made. For HTTP requests this is one of the HTTP request methods: GET, PUT, POST, HEAD.

SCRIPT_NAME
Contains the virtual path of the script being executed. This is useful for scripts that generate documents containing links that reference the scripts themselves.

SERVER_NAME
Set to the host-name of the system on which the server is running. This can be the true host-name, an alias or a numeric Internet address.

SERVER_PORT
The port number on which the request was received.

SERVER_PROTOCOL
Set to the name and version of the protocol with which the request was made. This will usually be HTTP/1.0.

SERVER_SOFTWARE
Identifies the server software being used, giving the name and version number, for example CERN/3.0.

Information in HTTP headers may be passed by the server to the script in environment variables with names formed by prefixing the header name with HTTP_. The most common variables of this type are:

HTTP_ACCEPT
Indicates the MIME content types that the browser is willing to accept.

HTTP_USER_AGENT
A string identifying the Web client. This is usually the name and version of the browser but may include other information such as the fact that the request was made through a proxy.


next up previous contents index
Next: Standard input stream Up: Inputs to the Previous: Command line arguments

[ITCP]Spinning the Web by Andrew Ford
© 1995 International Thomson Publishing
© 2002 Andrew Ford and Ford & Mason Ltd
Note: this HTML document was generated in December 1994 directly from the LaTeX source files using LaTeX2HTML. It was formatted into our standard page layout using the Template Toolkit. The document is mainly of historical interest as obviously many of the sites mentioned have long since disappeared.

 
Copyright © 1996-2002 Ford & Mason Ltd