getResponseHeader Method (ServerXMLHTTP-IServerXMLHTTPRequest)
Retrieves the value of an HTTP header from the response body.
JScript Syntax
strValue = oServerXMLHTTPRequest.getResponseHeader(bstrHeader);
Parameters
bstrHeader
A case-insensitive header name.
Example
var xmlServerHttp = new ActiveXObject("Msxml2.ServerXMLHTTP.6.0");
xmlServerHttp.open("GET", "https://localhost/sample.xml", false);
xmlServerHttp.send();
WScript.Echo(xmlServerHttp.getResponseHeader("Server"));
Output
Returns the value of the Server field in the HTTP header, which indicates the current version of the Web server running locally. In this case, the value is "Microsoft-IIS/5.1
" for Internet Information Services (IIS) version 5.1, which is the version provided if the local computer is running under Microsoft Windows XP.
C/C++ Syntax
HRESULT getResponseHeader(BSTR bstrHeader, BSTR* pbstrValue);
Parameters
bstrHeader
[in]
A case-insensitive header name.
pbstrValue
[out, retval]
The resulting header information.
Return Values
S_OK
The value returned if successful.
Remarks
The results of this method are valid only after the send
method has been successfully completed. The line, oServerXMLHTTPRequest.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.
Versioning
Implemented in: MSXML 3.0 and MSXML 6.0
Applies to
IServerXMLHTTPRequest-ServerXMLHTTP
See Also
getAllResponseHeaders Method (ServerXMLHTTP-IServerXMLHTTPRequest)
send Method (ServerXMLHTTP-IServerXMLHTTPRequest)
setRequestHeader Method (ServerXMLHTTP-IServerXMLHTTPRequest)