GetServerVariable

The GetServerVariable function retrieves information about a connection or about the server itself.

BOOL WINAPI GetServerVariable(

    HCONN hConn,

 

    LPSTR lpszVariableName,

 

    LPVOID lpvBuffer,

 

    LPDWORD lpdwSizeofBuffer

 

   );

 

 

Parameters

hConn

[in] The connection handle.

lpszVariableName

[in] A null-terminated string indicating which variable is being requested.

lpvBuffer

[out] A pointer to the buffer to receive the requested information.

lpdwSizeofBuffer

[in/out] A pointer to DWORD indicating the size of the buffer pointed to by lpvBuffer. On successful completion, the DWORD contains the size  of bytes transferred into the buffer, including the null-terminating byte.

 

Return Values

If the function is successful, a return value of TRUE is returned. If the function fails, a return value of FALSE is returned. The Win32 GetLastError function can be used to determine why the call failed.

Possible error values include:

Value

Meaning

ERROR_INVALID_PARAMETER

Bad connection handle.

ERROR_INVALID_INDEX

Bad or unsupported variable identifier.

ERROR_INSUFFICIENT_BUFFER

Buffer too small. The required buffer size is lpdwSize.

ERROR_MORE_DATA

Buffer too small. Only part of the data is returned. The total size of the data is not known.

ERROR_NO_DATA

The data requested is not available.

 

Remarks

The GetServerVariable function copies information into a buffer supplied by the caller. The information can include CGI variables and information relating to an HTTP connection or to the server itself.

Possible lpszVariableNames include:

AUTH_TYPE

This contains the type of authentication used. For example, the string will be  basic  if basic authentication is used, and it will be  NTLM  for Challenge-response. Other authentication schemes will have other strings. Since new authentication types can be added to the Internet Server, it is not possible to list all the string possibilities. If the string is empty, then no authentication is used.

CONTENT_LENGTH

The number of bytes which the script can expect to receive from the client.

CONTENT_TYPE

The content type of the information supplied in the body of a POST request.

PATH_INFO

Additional path information, as given by the client. This consists of the trailing part of the URL after the script name, but before the query string, if any.

PATH_TRANSLATED

This is the value of PATH_INFO, but with any virtual path name expanded into a directory specification.

QUERY_STRING

The information which follows the  ?  in the URL that referenced this script.

REMOTE_ADDR

The IP address of the client or agent of the client (for example, gateway or firewall) that sent the request.

REMOTE_HOST

The host name of the client or agent of the client (for example, gateway or firewall) that sent the request.

REMOTE_USER

This contains the user name supplied by the client and authenticated by the server. This comes back as an empty string when the user is anonymous (but authenticated).

UNMAPPED_REMOTE_USER

This is the user name before any ISAPI ApplicationsPI Filter mapped the user making the request to an NT user account (which appears as REMOTE_USER).

REQUEST_METHOD

The HTTP request method.

SCRIPT_NAME

The name of the script program being executed.

SERVER_NAME

The server's host name, or IP address, as it should appear in self-referencing URLs.

SERVER_PORT

The TCP/IP port on which the request was received.

SERVER_PORT_SECURE

A string of either zero or 1.  If the request is being handled on the secure port, then this will be 1. Otherwise, it will be zero.

SERVER_PROTOCOL

The name and version of the information retrieval protocol relating to this request. This is usually HTTP/1.0.

SERVER_SOFTWARE

The name and version of the Web server under which the ISAPI ApplicationsPI DLL program is running.

ALL_HTTP

All HTTP headers that were not already parsed into one of the previous variables. These variables are of the form HTTP_<header field name>. The headers consist of a null-terminated string with the individual headers separated by line feeds.

HTTP_ACCEPT

Special-case HTTP header. Values of the Accept: fields are concatenated, and separated by a comma ( , ). For example, if the following lines are part of the HTTP header:

   accept: */*; q=0.1
   accept: text/html
   accept: image/jpeg

the HTTP_ACCEPT variable will have a value of:

   */*; q=0.1, text/html, image/jpeg

URL (new for version 2.0)

Gives the base portion of the URL.

 

Note  In respect to Auth_Type, if the string is not empty it does not mean the user was authenticated, (if the authentication scheme is not "basic" or "NTLM").  The server allows authentication schemes it does not natively understand since an ISAPI ApplicationsPI Filter may be able to handle that particular scheme.