Retrieves header information associated with an HTTP request.
Syntax
BOOL HttpQueryInfo( IN HINTERNET hRequest, IN DWORD dwInfoLevel, IN LPVOID lpvBuffer, IN LPDWORD lpdwBufferLength, IN OUT LPDWORD lpdwIndex, );The actual syntax of this function varies between its ANSI and Unicode implementations. For more information, see Win32 Internet Functions Syntax.
Parameters
- hRequest
- HINTERNET request handle returned by HttpOpenRequest or InternetOpenUrl.
- dwInfoLevel
- Unsigned long integer value that contains a combination of an attribute to retrieve and the flags that modify the request. The attribute can be any one of the Attributes, and the flag can be any one of the Modifiers on the Query Info Flags page.
- lpvBuffer
- Address of the buffer that receives the information.
- lpdwBufferLength
- Address of a value that contains the length of the data buffer, in TCHARs. When the function returns, this parameter contains the address of a value specifying the length of the information written to the buffer. When the function returns strings, the following rules apply:
- If the function succeeds, lpdwBufferLength specifies the length of the string, in TCHARs, minus 1 for the terminating null.
- If the function fails and ERROR_INSUFFICIENT_BUFFER is returned, lpdwBufferLength specifies the number of bytes that the application must allocate to receive the string.
- lpdwIndex
- Address of 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 different types of data from HttpQueryInfo:
- Strings (default)
- SYSTEMTIME (for Data: Expires:, headers)
- DWORD (for STATUS_CODE, CONTENT_LENGTH, and so on, if HTTP_QUERY_FLAG_NUMBER has been used)
If your application needs the data returned as a data type other than a string, you must include the appropriate modifier with the attribute passed to dwInfoLevel.
Example
This example demonstrates a call to HttpQueryInfo.
bRet = HttpQueryInfo(hResource, HTTP_QUERY_RAW_HEADERS_CRLF, lpvSomeBuffer, &dwSize, NULL));
Function Information
Windows NT Use version 4.0. Implemented as ANSI and Unicode functions. Windows Use Windows 95 and later. Implemented as ANSI and Unicode functions. Header Wininet.h Import library Wininet.lib Minimum availability Internet Explorer 3.0 (ANSI only), 5 (ANSI and Unicode)
Windows CE
Windows CE Use version 2.12 and later. Implemented as ANSI and Unicode functions. Minimum availability Internet Explorer 4.0
See Also
Microsoft Win32 Internet Functions Overview, HTTP Sessions, Microsoft Win32 Internet Functions Reference, Microsoft Win32 Internet Functions Tutorials, Retrieving HTTP Headers, HTTP Functions