Mozilla XUL Element and Script Reference

Contents  Quick Reference


This object can be used to make HTTP requests. You can set headers and the method (GET or POST) before making the request. Once the connection has been made you can retrieve response headers and the returned content as plain text or as a parsed document.

Properties and Methods:

abort ( )

Stops the request if it already in progress.


The nsIHTTPChannel object used to perform the request.

getAllResponseHeaders ( )

Returns the HTTP response headers as a single string. The value will be null if the response is not available yet.

getAllResponseHeader ( header )

Returns the value of the HTTP response header with the given name. The value will be null if the response is not available yet.


This property should be set to a function which be called if an error occurs.


This property should be set to a function which will be called when the request has completed and the response has been fully received.

open ( method , url )
open ( method , url , async , user , password )

Initialize an HTTP request for a given URL. The method argument should be set to either the string 'GET' or 'POST'. The request is not made until the send function is called. The async argument, if true will cause the request to be performed asynchronously. The function in the onload property is called when the response is received. If the async argument is false, the send function will wait until the response is fully received. The default value is true. You can also optionally supply a user and password if the URL requires it.


The response to the request as text. The property is read-only.


The response to the request as a new document object. The property is read-only.

send ( body )

Initiates the request, sending the body as the post data. The body should be either a string of XML, a document, or a stream.

setRequestHeader ( header , value )

Sets a request header. You should only call this function before calling the send function.


The status code of the response, which will be an HTTP response code. For example, the value will be 200 if the request was successful. The property is read-only.


Gets and sets the value of the statustext attribute.