setRequestHeader method (Internet Explorer)

Switch View :
ScriptFree
setRequestHeader method

[This documentation is preliminary and is subject to change.]

Adds custom HTTP headers to the request.

Syntax

var retval = XMLHttpRequest.setRequestHeader(bstrHeader, bstrValue);

Standards information

Parameters

bstrHeader [in]

Type: BSTR

String that specifies the header name.

bstrValue [in]

Type: BSTR

String that specifies the header value.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

Refer to RFC2616, Section 14: Header Field Definitions for a general list of standard headers. The server is ultimately responsible for honoring the headers of the request. By far the most common request header is Content-Type, which is required by some XML Web services.

setRequestHeader was introduced in Windows Internet Explorer 7.

Examples

The following script sets the HTTP Content-Type header to 'text/xml' before sending the request body:


var oReq = new XMLHttpRequest();
oReq.open("POST", sURL, false);
oReq.setRequestHeader("Content-Type", "text/xml");
oReq.send(sRequestBody);

See also

XMLHttpRequest
getResponseHeader

 

 

Build date: 2/14/2012