次の方法で共有


GetResponseHeader Method (IXMLHTTPRequest2, Windows 8)

 

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

C/C++ Syntax

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.  

Remarks

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.

Versioning

Implemented in: MSXML 6.0

Applies to

IXMLHTTPRequest2 (Windows 8)

See Also

GetAllResponseHeaders Method (IXMLHTTPRequest2, Windows 8)
Send Method (IXMLHTTPRequest2, Windows 8)
SetRequestHeader Method (IXMLHTTPRequest2, Windows 8)
CoTaskMemFree Function