Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
GetResponseHeader Method (IXMLHTTPRequest2, Windows 8)
Collapse the table of content
Expand the table of content

GetResponseHeader Method (IXMLHTTPRequest2, Windows 8)

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

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


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


The value returned if successful.


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

// Create XMLHTTPRequest2 object and initialize pIXMLHTTP2Request.
hr = pIXMLHttpRequest2->getResponseHeader(L"Server"), &pwszHeaderValue);
   ::MessageBox(NULL, m_pwszHeaderValue, L"Response Header-Server", MB_OK);   
   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

© 2015 Microsoft