Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function retrieves information about an HTTP connection or about IIS itself.
Some server variables, such as Request_Method and Content_Length are embedded in the EXTENSION_CONTROL_BLOCKstructure. You can use GetServerVariableto obtain information about the request or server that is not included in the EXTENSION_CONTROL_BLOCK.
BOOL WINAPI GetServerVariable( HCONN hConn , LPSTR lpszVariableName , LPVOID lpvBuffer , LPDWORD lpdwSizeofBuffer );
Parameters
Variable | Description |
---|---|
ALL_RAW | Retrieves all headers in raw form. The header names and values appear as they are sent by the client. Currently, this value is primarily used by proxy servers and other similar applications. |
AUTH_PASSWORD | Specifies the value entered in the client's authentication dialog. This variable is only available if Basic authentication is used. |
AUTH_TYPE | Specifies the type of authentication used. If the string is empty, then no authentication is used. Possible values are Kerberos, user, SSL/PCT, Basic, and integrated Windows authentication. |
AUTH_USER | Specifies the value entered in the client's authentication dialog box. |
CONTENT_LENGTH | Specifies the number of bytes of data that the script or extension can expect to receive from the client. This total does not include headers. |
CONTENT_TYPE | Specifies the content type of the information supplied in the body of a POST request. |
HTTPS | Returns on if the request came in through secure channel (with SSL encryption), or off if the request is for an unsecure channel. |
PATH_INFO | Specifies the additional path information, as given by the client. This consists of the trailing part of the URL after the script or ISAPI DLL name, but before the query string, if any. |
PATH_TRANSLATED | Specifies this is the value of PATH_INFO, but with any virtual path expanded into a directory specification. |
QUERY_STRING | Specifies the information that follows the first question mark in the URL that referenced this script. |
REMOTE_ADDR | Specifies the IP address of the client or agent of the client (for example gateway, proxy, or firewall) that sent the request. |
REMOTE_USER | Specifies the user name supplied by the client and authenticated by the server. This comes back as an empty string when the user is anonymous. |
REQUEST_METHOD | Specifies the HTTP request method verb. |
SCRIPT_NAME | Specifies the name of the script program being executed. |
SERVER_NAME | Specifies the server's host name, or IP address, as it should appear in self-referencing URLs. |
SERVER_PORT | Specifies the TCP/IP port on which the request was received. |
SERVER_PORT_SECURE | Specifies a string of either 0 or 1. If the request is being handled on the secure port, then this will be 1. Otherwise, it will be 0. |
SERVER_PROTOCOL | Specifies the name and version of the information retrieval protocol relating to this request. |
SERVER_SOFTWARE | Specifies the name and version of the Web server under which the ISAPI extension DLL program is running. |
URL | Specifies the base portion of the URL. Parameter values will not be included. The value is determined when IIS parses the URL from the header. |
Return Values
If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. The GetLastErrorfunction can be used to determine why the call failed. The following are the possible error values.
Value | Description |
---|---|
ERROR_INVALID_PARAMETER | Bad connection handle, or invalid values, in either lpszVariableNameor lpdwSizeOfBuffer. |
ERROR_INVALID_INDEX | Bad or unsupported variable identifier. |
ERROR_INSUFFICIENT_BUFFER | Buffer too small. The required buffer size is * lpdwSizeofBuffer. |
ERROR_NO_DATA | The data requested is not available. |
Remarks
The GetServerVariablefunction 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.
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 integrated Windows authentication). The server allows authentication schemes it does not natively support because an ISAPI filter may be able to handle that particular scheme.
The lpszVariableNamecan be used to retrieve a specific request (client) header by using the HTTP_ headernamevalue. For example, supplying the value HTTP_ACCEPT returns the Accept header, and HTTP_VERSION returns the Version header.
The values of the fields for the HTTP_ACCEPT variable are concatenated, and separated by a comma (,).
Requirements
Runs On | Versions | Defined in | Include | Link to |
---|---|---|---|---|
Windows CE OS | 3.0 and later | httpext.h | Httpfilt.lib |
Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.
See Also
GetLastError, EXTENSION_CONTROL_BLOCK