Retrieves the value of a server environment variable.
PSDocumentClass object
psDocument.GetEnv( envvar )
Argument |
Description |
---|---|
envvar |
The name of a server environment variable |
String. Returns the value of the specified server environment variable. Returns null if the server environment variable does not exist.
The server environment variables that can be specified in GetEnv vary depending on which application server you deploy to. Here are the most common server environment variables:
Server environment variable |
Description |
---|---|
AUTH_TYPE |
The authentication method that the server uses to validate users who try to access protected scripts. |
CONTENT_LENGTH |
The length of the data message sent to the server. Applies only to queries that have information attached (such as those that use the POST and PUT methods). |
CONTENT_TYPE |
The datatype for the message sent to the server. Applies only to queries that have information attached (such as those that use the POST and PUT methods). |
GATEWAY_INTERFACE |
The version of the CGI interface specification being used by the server. |
HTTP_headername |
The contents of the specified request header. The server interprets any underscores (_) in headername as dashes in the actual header. For example, if you specify HTTP_MY_HEADER, the server searches for a header sent as MY-HEADER. |
PATH_INFO |
Extra path information found in the URL. PATH_INFO is the part of the URL found after the script name but before the query string. |
PATH_TRANSLATED |
The value of PATH_INFO along with the virtual path converted to a physical directory name. |
QUERY_STRING |
The query information stored in the string following the question mark (?) in the HTTP request. |
REMOTE_ADDR |
The IP address of the client making the request. |
REMOTE_HOST |
The domain name of the client making the request. |
REQUEST_METHOD |
The method used to make the request. For HTTP, this is GET, HEAD, POST, PUT, and so on. |
SCRIPT_NAME |
A virtual path to the script being executed. SCRIPT_NAME is used to construct URLs that refer back to the same gateway program script. |
SERVER_NAME |
The domain name of the server. |
SERVER_PORT |
The TCP/IP port that received the request. |
SERVER_PROTOCOL |
The name and version of the protocol (for example, HTTP/1.0). |
SERVER_SOFTWARE |
The name and version of the Web server software (for example, NCSA/1.3). |
For a complete list of the server environment variables supported on your server platform, see your server documentation.
At runtime, GetEnv calls the mapped method in the ENVPARAM class.
The following example retrieves the IP address of the remote host making the current request:
remaddr = psDocument.GetEnv("REMOTE_ADDR");