IXMLHTTPRequest2::GetResponseHeader method (msxml6.h)

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

Syntax

HRESULT GetResponseHeader(
  [in]            const WCHAR *pwszHeader,
  [out, optional] WCHAR       **ppwszValue
);

Parameters

[in] pwszHeader

A case-insensitive header name.

[out, optional] ppwszValue

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

Return value

Returns S_OK on success.

Remarks

The results of this method are valid only after OnHeadersAvailable callback method has been called.

Examples

HRESULT hr = S_OK;
WCHAR *pwszHeaderValue = NULL;
IXMLHTTPRequest2 *pIXMLHTTPRequest2 = NULL;

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

if (pwszHeaderValue != NULL)
{
   CoTaskMemFree(pwszHeaderValue);
   pwszHeaderValue = NULL;
}

// Release pIXMLHTTPRequest2 when finished with it.

Requirements

   
Minimum supported client Windows 8 [desktop apps | UWP apps],MSXML 6.0 and later
Minimum supported server Windows Server 2012 [desktop apps | UWP apps]
Target Platform Windows
Header msxml6.h

See also

CoTaskMemFree

GetAllResponseHeaders

IXMLHTTPRequest2

OnHeadersAvailable