Export (0) Print
Expand All
DOM
Expand Minimize

GetResponseHeader Method (IXMLHTTPRequest2, Windows 8)

Retrieves the value of an HTTP header from the HTTP response headers.

HRESULT GetResponseHeader(const WCHAR *pwszHeader, WCHAR *ppwszValue);

Parameters

pwszHeader [in, string, ref]

A case-insensitive header name.

ppwszValue [out, string]

The resulting header information. You should free the memory for this parameter by calling the CoTaskMemFree function.

Return Values

S_OK

The value returned if successful.

Example

HRESULT hr;
const WCHAR pwszHeaderValue = NULL;
IXMLHttpRequest2 *pIXMLHttpRequest2 = NULL;

// Create XMLHTTPRequest2 object and initialize pIXMLHTTP2Request.
hr = pIXMLHttpRequest2->getResponseHeader(L"Server"), &pwszHeaderValue);
if(SUCCEEDED(hr))
{
   ::MessageBox(NULL, m_pwszHeaderValue, L"Response Header-Server", MB_OK);   
   ::SysFreeString(pwszHeaderValue);
   pwszHeaderValue = NULL;
}   

// Release pIXMLHttpRequest2 when finished with it.

The results of this method are valid only after the OnHeadersAvailable callback has been executed. The line xmlhttp.getResponseHeader("Content-Type"); returns the string "text/xml", assuming the server set "text/xml" as the content type. Call the GetAllResponseHeaders method to receive the full list of header variables you can query.

Implemented in: MSXML 6.0

Show:
© 2014 Microsoft