Struct xpcom::interfaces::nsIXMLHttpRequest
[−]
[src]
#[repr(C)]pub struct nsIXMLHttpRequest { /* fields omitted */ }
interface nsIXMLHttpRequest : nsISupports
/**
* Mozilla's XMLHttpRequest is modelled after Microsoft's IXMLHttpRequest
* object. The goal has been to make Mozilla's version match Microsoft's
* version as closely as possible, but there are bound to be some differences.
*
* In general, Microsoft's documentation for IXMLHttpRequest can be used.
* Mozilla's interface definitions provide some additional documentation. The
* web page to look at is http://www.mozilla.org/xmlextras/
*
* Mozilla's XMLHttpRequest object can be created in JavaScript like this:
* new XMLHttpRequest()
* compare to Internet Explorer:
* new ActiveXObject("Msxml2.XMLHTTP")
*
* From native code, the way to set up onload and onerror handlers is a bit
* different. Here is a comment from Johnny Stenback <jst@netscape.com>:
*
* The mozilla implementation of nsIXMLHttpRequest implements the interface
* nsIDOMEventTarget and that's how you're supported to add event listeners.
* Try something like this:
*
* nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(myxmlhttpreq));
*
* target->AddEventListener(NS_LITERAL_STRING("load"), mylistener,
* PR_FALSE)
*
* where mylistener is your event listener object that implements the
* interface nsIDOMEventListener.
*
* Conclusion: Do not use event listeners on XMLHttpRequest from C++, unless
* you're aware of all the security implications. And then think twice about
* it.
*/
Methods
impl nsIXMLHttpRequest
[src]
pub fn coerce<T: nsIXMLHttpRequestCoerce>(&self) -> &T
[src]
Cast this nsIXMLHttpRequest
to one of its base interfaces.
impl nsIXMLHttpRequest
[src]
pub const UNSENT: i64
UNSENT: i64 = 0
/**
* The state of the request.
*
* Possible values:
* 0 UNSENT open() has not been called yet.
* 1 OPENED send() has not been called yet.
* 2 HEADERS_RECEIVED
* send() has been called, headers and status are available.
* 3 LOADING Downloading, responseText holds the partial data.
* 4 DONE Finished with all operations.
*/
pub const OPENED: i64
OPENED: i64 = 1
pub const HEADERS_RECEIVED: i64
HEADERS_RECEIVED: i64 = 2
pub const LOADING: i64
LOADING: i64 = 3
pub const DONE: i64
DONE: i64 = 4
pub unsafe fn GetChannel(&self, aChannel: *mut *const nsIChannel) -> nsresult
[src]
/**
* The request uses a channel in order to perform the
* request. This attribute represents the channel used
* for the request. NULL if the channel has not yet been
* created.
*
* Mozilla only. Requires elevated privileges to access.
*/
readonly attribute nsIChannel channel;
pub unsafe fn GetResponseXML(
&self,
aResponseXML: *mut *const nsIDOMDocument
) -> nsresult
[src]
&self,
aResponseXML: *mut *const nsIDOMDocument
) -> nsresult
/**
* The response to the request is parsed as if it were a
* text/xml stream. This attributes represents the response as
* a DOM Document object. NULL if the request is unsuccessful or
* has not yet been sent.
*/
readonly attribute nsIDOMDocument responseXML;
pub unsafe fn GetResponseText(&self, aResponseText: &mut nsAString) -> nsresult
[src]
/**
* The response to the request as text.
* NULL if the request is unsuccessful or
* has not yet been sent.
*/
readonly attribute AString responseText;
pub unsafe fn GetResponseType(&self, aResponseType: &mut nsAString) -> nsresult
[src]
/**
* Determine a response format which response attribute returns.
* empty string (initial value) or "text": as text.
* "arraybuffer": as a typed array ArrayBuffer.
* "blob": as a File API Blob.
* "document": as a DOM Document object.
*/
attribute AString responseType;
pub unsafe fn SetResponseType(&self, aResponseType: &nsAString) -> nsresult
[src]
/**
* Determine a response format which response attribute returns.
* empty string (initial value) or "text": as text.
* "arraybuffer": as a typed array ArrayBuffer.
* "blob": as a File API Blob.
* "document": as a DOM Document object.
*/
attribute AString responseType;
pub unsafe fn GetStatus(&self, aStatus: *mut uint32_t) -> nsresult
[src]
/**
* The status of the response to the request for HTTP requests.
*/
readonly attribute unsigned long status;
pub unsafe fn GetStatusText(&self, aStatusText: &mut nsACString) -> nsresult
[src]
/**
* The string representing the status of the response for
* HTTP requests.
*/
readonly attribute ACString statusText;
pub unsafe fn SlowAbort(&self) -> nsresult
[src]
/**
* If the request has been sent already, this method will
* abort the request.
*/
[binaryname(SlowAbort)] void abort ();
pub unsafe fn GetAllResponseHeaders(&self, _retval: &mut nsACString) -> nsresult
[src]
/**
* Returns all of the response headers as a string for HTTP
* requests.
*
* @returns A string containing all of the response headers.
* The empty string if the response has not yet been received.
*/
ACString getAllResponseHeaders ();
pub unsafe fn GetResponseHeader(
&self,
header: &nsACString,
_retval: &mut nsACString
) -> nsresult
[src]
&self,
header: &nsACString,
_retval: &mut nsACString
) -> nsresult
/**
* Returns the text of the header with the specified name for
* HTTP requests.
*
* @param header The name of the header to retrieve
* @returns A string containing the text of the header specified.
* NULL if the response has not yet been received or the
* header does not exist in the response.
*/
ACString getResponseHeader (in ACString header);
pub unsafe fn Send(&self, body: *const nsIVariant) -> nsresult
[src]
/**
* Sends the request. If the request is asynchronous, returns
* immediately after sending the request. If it is synchronous
* returns only after the response has been received.
*
* All event listeners must be set before calling send().
*
* After the initial response, all event listeners will be cleared.
* // XXXbz what does that mean, exactly?
*
* @param body Either an instance of nsIDOMDocument, nsIInputStream
* or a string (nsISupportsString in the native calling
* case). This is used to populate the body of the
* HTTP request if the HTTP request method is "POST".
* If the parameter is a nsIDOMDocument, it is serialized.
* If the parameter is a nsIInputStream, then it must be
* compatible with nsIUploadChannel.setUploadStream, and a
* Content-Length header will be added to the HTTP request
* with a value given by nsIInputStream.available. Any
* headers included at the top of the stream will be
* treated as part of the message body. The MIME type of
* the stream should be specified by setting the Content-
* Type header via the setRequestHeader method before
* calling send.
*/
void send ([optional] in nsIVariant body);
pub unsafe fn SetRequestHeader(
&self,
header: &nsACString,
value: &nsACString
) -> nsresult
[src]
&self,
header: &nsACString,
value: &nsACString
) -> nsresult
/**
* Sets a HTTP request header for HTTP requests. You must call open
* before setting the request headers.
*
* @param header The name of the header to set in the request.
* @param value The body of the header.
*/
void setRequestHeader (in ACString header, in ACString value);
pub unsafe fn GetTimeout(&self, aTimeout: *mut uint32_t) -> nsresult
[src]
/**
* The amount of milliseconds a request can take before being terminated.
* Initially zero. Zero means there is no timeout.
*/
attribute unsigned long timeout;
pub unsafe fn SetTimeout(&self, aTimeout: uint32_t) -> nsresult
[src]
/**
* The amount of milliseconds a request can take before being terminated.
* Initially zero. Zero means there is no timeout.
*/
attribute unsigned long timeout;
pub unsafe fn GetReadyState(&self, aReadyState: *mut uint16_t) -> nsresult
[src]
readonly attribute unsigned short readyState;
pub unsafe fn SlowOverrideMimeType(&self, mimetype: &nsAString) -> nsresult
[src]
/**
* Override the mime type returned by the server (if any). This may
* be used, for example, to force a stream to be treated and parsed
* as text/xml, even if the server does not report it as such. This
* must be done before the <code>send</code> method is invoked.
*
* @param mimetype The type used to override that returned by the server
* (if any).
*/
[binaryname(SlowOverrideMimeType)] void overrideMimeType (in DOMString mimetype);
pub unsafe fn GetMozBackgroundRequest(
&self,
aMozBackgroundRequest: *mut bool
) -> nsresult
[src]
&self,
aMozBackgroundRequest: *mut bool
) -> nsresult
/**
* Set to true if this is a background service request. This will
* prevent a load group being associated with the request, and
* suppress any security dialogs from being shown * to the user.
* In the cases where one of those dialogs would be shown, the request
* will simply fail instead.
*/
attribute boolean mozBackgroundRequest;
pub unsafe fn SetMozBackgroundRequest(
&self,
aMozBackgroundRequest: bool
) -> nsresult
[src]
&self,
aMozBackgroundRequest: bool
) -> nsresult
/**
* Set to true if this is a background service request. This will
* prevent a load group being associated with the request, and
* suppress any security dialogs from being shown * to the user.
* In the cases where one of those dialogs would be shown, the request
* will simply fail instead.
*/
attribute boolean mozBackgroundRequest;
pub unsafe fn GetWithCredentials(&self, aWithCredentials: *mut bool) -> nsresult
[src]
/**
* When set to true attempts to make cross-site Access-Control requests
* with credentials such as cookies and authorization headers.
*
* Never affects same-site requests.
*
* Defaults to false.
*/
attribute boolean withCredentials;
pub unsafe fn SetWithCredentials(&self, aWithCredentials: bool) -> nsresult
[src]
/**
* When set to true attempts to make cross-site Access-Control requests
* with credentials such as cookies and authorization headers.
*
* Never affects same-site requests.
*
* Defaults to false.
*/
attribute boolean withCredentials;
pub unsafe fn Init(
&self,
principal: *const nsIPrincipal,
globalObject: *const nsIGlobalObject,
baseURI: *const nsIURI,
loadGroup: *const nsILoadGroup
) -> nsresult
[src]
&self,
principal: *const nsIPrincipal,
globalObject: *const nsIGlobalObject,
baseURI: *const nsIURI,
loadGroup: *const nsILoadGroup
) -> nsresult
/**
* Initialize the object for use from C++ code with the principal, script
* context, and owner window that should be used.
*
* @param principal The principal to use for the request. This must not be
* null.
* @param globalObject The associated global for the request. Can be the
* outer window, a sandbox, or a backstage pass.
* May be null, but then the request cannot create a
* document.
* @param baseURI The base URI to use when resolving relative URIs. May be
* null.
* @param loadGroup An optional load group to use when performing the request.
* This will be used even if the global has a window with a
* load group.
*/
[noscript] void init (in nsIPrincipal principal, in nsIGlobalObject globalObject, in nsIURI baseURI, [optional] in nsILoadGroup loadGroup);
pub unsafe fn GetUpload(
&self,
aUpload: *mut *const nsIXMLHttpRequestUpload
) -> nsresult
[src]
&self,
aUpload: *mut *const nsIXMLHttpRequestUpload
) -> nsresult
/**
* Upload process can be tracked by adding event listener to |upload|.
*/
readonly attribute nsIXMLHttpRequestUpload upload;
pub unsafe fn GetMozAnon(&self, aMozAnon: *mut bool) -> nsresult
[src]
/**
* If true, the request will be sent without cookie and authentication
* headers.
*/
readonly attribute boolean mozAnon;
pub unsafe fn GetMozSystem(&self, aMozSystem: *mut bool) -> nsresult
[src]
/**
* If true, the same origin policy will not be enforced on the request.
*/
readonly attribute boolean mozSystem;
Methods from Deref<Target = nsISupports>
pub fn coerce<T: nsISupportsCoerce>(&self) -> &T
[src]
Cast this nsISupports
to one of its base interfaces.
pub unsafe fn QueryInterface(
&self,
uuid: &nsIID,
result: *mut *mut c_void
) -> nsresult
[src]
&self,
uuid: &nsIID,
result: *mut *mut c_void
) -> nsresult
void QueryInterface (in nsIIDRef uuid, [iid_is (uuid), retval] out nsQIResult result);
pub unsafe fn AddRef(&self) -> nsrefcnt
[src]
[noscript,notxpcom] nsrefcnt AddRef ();
pub unsafe fn Release(&self) -> nsrefcnt
[src]
[noscript,notxpcom] nsrefcnt Release ();
Trait Implementations
impl XpCom for nsIXMLHttpRequest
[src]
const IID: nsIID
IID: nsIID = nsID(1867784524, 29045, 18829, [157, 45, 4, 41, 227, 140, 40, 105])
fn query_interface<T: XpCom>(&self) -> Option<RefPtr<T>>
[src]
Perform a QueryInterface call on this object, attempting to dynamically cast it to the requested interface type. Returns Some(RefPtr) if the cast succeeded, and None otherwise. Read more
impl RefCounted for nsIXMLHttpRequest
[src]
unsafe fn addref(&self)
[src]
Increment the reference count.
unsafe fn release(&self)
[src]
Decrement the reference count, potentially freeing backing memory.
impl Deref for nsIXMLHttpRequest
[src]
type Target = nsISupports
The resulting type after dereferencing.
fn deref(&self) -> &nsISupports
[src]
Dereferences the value.