Retrieves header information associated with an HTTP request.
Syntax
BOOL HttpQueryInfo(
__in HINTERNET hRequest,
__in DWORD dwInfoLevel,
__inout LPVOID lpvBuffer,
__inout LPDWORD lpdwBufferLength,
__inout LPDWORD lpdwIndex
);
Parameters
- hRequest
-
Handle returned by
HttpOpenRequest or
InternetOpenUrl.
- dwInfoLevel
-
Combination of an attribute to be retrieved and flags that modify the request. For a list of possible attribute and modifier values, see
Query Info Flags.
- lpvBuffer
-
Pointer to a buffer to receive the requested information. This parameter must not be NULL.
- lpdwBufferLength
-
Pointer to a variable that contains, on entry, the size in bytes of the buffer pointed to by lpvBuffer.
When the function returns successfully, this variable contains the number of bytes of information written to the buffer. In the case of a string, the byte count does not include the string's terminating null character.
When the function
fails with an extended error code of ERROR_INSUFFICIENT_BUFFER, the variable pointed to by lpdwBufferLength contains on exit the size, in bytes, of a buffer large enough to receive the requested information. The calling application can then allocate a buffer of this size or larger, and call the function again.
- lpdwIndex
-
Pointer to a zero-based header index used to enumerate multiple headers with the same name. When calling the function, this parameter is the index of the specified header to return. When the function returns, this parameter is the index of the next header. If the next index cannot be found, ERROR_HTTP_HEADER_NOT_FOUND is returned.
Return Value
Returns TRUE if successful, or FALSE otherwise. To get extended error information, call
GetLastError.
Remarks
You can retrieve the following types of data from
HttpQueryInfo:
- Strings (default)
- SYSTEMTIME (for dates)
- DWORD (for STATUS_CODE, CONTENT_LENGTH, and so on, if HTTP_QUERY_FLAG_NUMBER has been used)
If your application requires that the data be returned as a data type other than a string, you must include the appropriate modifier with the attribute passed to
dwInfoLevel.
HttpQueryInfo is available in Microsoft Internet Explorer 3.0 for the ANSI character set and in Internet Explorer 4.0 or later for ANSI and Unicode characters.
Example Code
This example demonstrates a call to
HttpQueryInfo.
bRet = HttpQueryInfo(hResource, HTTP_QUERY_RAW_HEADERS_CRLF,
lpvSomeBuffer, &dwSize, NULL);
Requirements
Client | Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0, Windows Me, Windows 98, or Windows 95. |
Server | Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0. |
Version | Requires Internet Explorer 3.0 or later. |
Header | Declared in Wininet.h. |
Library | Use Wininet.lib. |
DLL | Requires Wininet.dll. |
Unicode | Implemented as HttpQueryInfoW (Unicode) and HttpQueryInfoA (ANSI). |
See Also
HTTP Sessions
WinINet Functions
Retrieving HTTP Headers
Send comments about this topic to Microsoft
Build date: 2/28/2008