Retrieves the value of an HTTP header from the response body.
strValue = oXMLHttpRequest.getResponseHeader(bstrHeader);
A string. Contains the resulting header information.
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.5.0");
xmlhttp.open("GET", "http://localhost/sample.xml", false);
xmlhttp.send();
alert(xmlhttp.getResponseHeader("Content-Length"));
strValue = oXMLHttpRequest.getResponseHeader(bstrHeader)
A string. Contains the resulting header information.
Dim xmlhttp As New Msxml2.XMLHTTP50
xmlhttp.open "GET", "http://localhost/sample.xml", False
xmlhttp.send
MsgBox xmlhttp.getResponseHeader("Content-Length")
HRESULT getResponseHeader(BSTR bstrHeader, BSTR* pbstrValue);
HRESULT hr;
BSTR bstrValue = NULL;
IXMLHttpRequest *pIXMLHttpRequest = NULL;
try
{
// Create XMLHttpRequest object and initialize pIXMLHttpRequest.
hr = pIXMLHttpRequest->getResponseHeader(_T("Server"), &bstrValue);
if(SUCCEEDED(hr))
{
::MessageBox(NULL, m_bstrValue, _T("Response Header-Server"), MB_OK);
::SysFreeString(bstrValue);
bstrValue = NULL;
}
}
catch(...)
{
if(bstrValue)
::SysFreeString(bstrValue);
DisplayErrorToUser();
}
// Release pIXMLHttpRequest when finished with it.
The results of this method are valid only after the send method has been successfully completed. The line, xmlhttp.getResponseHeader("Content-Type");, returns the string "text/xml", assuming the server set "text/xml" as the content type. The full list of header variables you can query can be accessed from the getAllResponseHeaders method.
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button
in the upper-left corner of the page.
getAllResponseHeaders Method (IXMLHTTPRequest) | send Method (IXMLHTTPRequest) | setRequestHeader Method (IXMLHTTPRequest)
Applies to: IXMLHTTPRequest