2006-04-20 07:36:50 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
|
|
|
interface nsIDOMDocument;
|
|
|
|
interface nsIDOMEventListener;
|
2006-04-20 07:37:29 +04:00
|
|
|
interface nsIChannel;
|
2006-04-20 07:36:50 +04:00
|
|
|
|
|
|
|
[scriptable, uuid(b7215e70-4157-11d4-9a42-000064657374)]
|
|
|
|
interface nsIXMLHttpRequest : nsISupports {
|
2006-04-20 07:37:01 +04:00
|
|
|
/**
|
2006-04-20 07:37:29 +04:00
|
|
|
* 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
|
2006-04-20 07:37:01 +04:00
|
|
|
* created.
|
|
|
|
*/
|
2006-04-20 07:37:29 +04:00
|
|
|
readonly attribute nsIChannel channel;
|
2006-04-20 07:37:01 +04:00
|
|
|
|
2006-04-20 07:36:55 +04:00
|
|
|
/**
|
2006-04-20 07:37:29 +04:00
|
|
|
* The response to the request is parsed as if it were a
|
2006-04-20 07:36:55 +04:00
|
|
|
* 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.
|
|
|
|
*/
|
2006-04-20 07:36:50 +04:00
|
|
|
readonly attribute nsIDOMDocument responseXML;
|
2006-04-20 07:36:55 +04:00
|
|
|
|
2006-04-20 07:37:08 +04:00
|
|
|
/**
|
2006-04-20 07:37:29 +04:00
|
|
|
* The response to the request as text.
|
2006-04-20 07:37:08 +04:00
|
|
|
* NULL if the request is unsuccessful or
|
|
|
|
* has not yet been sent.
|
|
|
|
*/
|
|
|
|
readonly attribute wstring responseText;
|
|
|
|
|
|
|
|
|
2006-04-20 07:36:55 +04:00
|
|
|
/**
|
2006-04-20 07:37:29 +04:00
|
|
|
* The status of the response to the request for HTTP requests.
|
2006-04-20 07:36:55 +04:00
|
|
|
*/
|
2006-04-20 07:36:50 +04:00
|
|
|
readonly attribute unsigned long status;
|
2006-04-20 07:36:55 +04:00
|
|
|
|
|
|
|
/**
|
2006-04-20 07:37:29 +04:00
|
|
|
* The string representing the status of the response for
|
|
|
|
* HTTP requests.
|
2006-04-20 07:36:55 +04:00
|
|
|
*/
|
2006-04-20 07:36:50 +04:00
|
|
|
readonly attribute string statusText;
|
|
|
|
|
2006-04-20 07:36:55 +04:00
|
|
|
/**
|
2006-04-20 07:37:29 +04:00
|
|
|
* If the request has been sent already, this method will
|
2006-04-20 07:36:55 +04:00
|
|
|
* abort the request.
|
|
|
|
*/
|
2006-04-20 07:36:50 +04:00
|
|
|
void abort();
|
2006-04-20 07:36:55 +04:00
|
|
|
|
|
|
|
/**
|
2006-04-20 07:37:29 +04:00
|
|
|
* Returns all of the response headers as a string for HTTP
|
|
|
|
* requests.
|
2006-04-20 07:36:55 +04:00
|
|
|
*
|
|
|
|
* @returns A string containing all of the response headers.
|
|
|
|
* NULL if the response has not yet been received.
|
|
|
|
*/
|
2006-04-20 07:36:50 +04:00
|
|
|
string getAllResponseHeaders();
|
2006-04-20 07:36:55 +04:00
|
|
|
|
|
|
|
/**
|
2006-04-20 07:37:29 +04:00
|
|
|
* Returns the text of the header with the specified name for
|
|
|
|
* HTTP requests.
|
2006-04-20 07:36:55 +04:00
|
|
|
*
|
|
|
|
* @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.
|
|
|
|
*/
|
2006-04-20 07:36:50 +04:00
|
|
|
string getResponseHeader(in string header);
|
2006-04-20 07:36:55 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Native (non-script) method to initialize a request. Note that
|
2006-04-20 07:37:29 +04:00
|
|
|
* the request is not sent until the <code>send</code> method
|
2006-04-20 07:36:55 +04:00
|
|
|
* is invoked.
|
|
|
|
*
|
2006-04-20 07:37:29 +04:00
|
|
|
* @param method The HTTP method - either "POST" or "GET". Ignored
|
|
|
|
* if the URL is not a HTTP URL.
|
2006-04-20 07:36:55 +04:00
|
|
|
* @param url The URL to which to send the request.
|
|
|
|
* @param async Whether the request is synchronous or asynchronous
|
|
|
|
* i.e. whether send returns only after the response
|
|
|
|
* is received or if it returns immediately after
|
|
|
|
* sending the request. In the latter case, notification
|
|
|
|
* of completion is sent through the event listeners.
|
|
|
|
* @param user A username for authentication if necessary.
|
|
|
|
* @param password A password for authentication if necessary.
|
|
|
|
*/
|
2006-04-20 07:36:52 +04:00
|
|
|
[noscript] void openRequest(in string method,
|
2006-04-20 07:36:55 +04:00
|
|
|
in string url,
|
|
|
|
in boolean async,
|
|
|
|
in string user,
|
|
|
|
in string password);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Meant to be a script-only method for initializing a request.
|
|
|
|
* The parameters are similar to the ones detailed in the
|
|
|
|
* description of <code>openRequest</code>, but the last
|
|
|
|
* 3 are optional.
|
|
|
|
*
|
2006-04-20 07:37:29 +04:00
|
|
|
* @param method The HTTP method - either "POST" or "GET". Ignored
|
|
|
|
* if the URL is not a HTTP URL.
|
2006-04-20 07:36:55 +04:00
|
|
|
* @param url The URL to which to send the request.
|
|
|
|
* @param async (optional) Whether the request is synchronous or
|
|
|
|
* asynchronous i.e. whether send returns only after
|
|
|
|
* the response is received or if it returns immediately after
|
|
|
|
* sending the request. In the latter case, notification
|
|
|
|
* of completion is sent through the event listeners.
|
|
|
|
* The default value is true.
|
|
|
|
* @param user (optional) A username for authentication if necessary.
|
|
|
|
* The default value is the empty string
|
|
|
|
* @param password (optional) A password for authentication if necessary.
|
|
|
|
* The default value is the empty string
|
|
|
|
*/
|
|
|
|
void open(in string method, in string url);
|
|
|
|
|
|
|
|
/**
|
2006-04-20 07:37:29 +04:00
|
|
|
* Sends the request. If the request is asynchronous, returns
|
2006-04-20 07:36:55 +04:00
|
|
|
* immediately after sending the request. If it is synchronous
|
|
|
|
* returns only after the response has been received.
|
|
|
|
*
|
|
|
|
* @param body Either an instance of nsIDOMDocument, nsIInputStream
|
|
|
|
* or a string (nsISupportsWString 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, it is expected
|
|
|
|
* to contain the ContentType: and ContentLength: headers
|
|
|
|
* and trailing carriage-return/line-feed pairs.
|
|
|
|
*/
|
2006-04-20 07:36:50 +04:00
|
|
|
void send(in nsISupports body);
|
2006-04-20 07:36:55 +04:00
|
|
|
|
|
|
|
/**
|
2006-04-20 07:37:29 +04:00
|
|
|
* Sets a HTTP request header for HTTP requests.
|
2006-04-20 07:36:55 +04:00
|
|
|
*
|
|
|
|
* @param header The name of the header to set in the request.
|
|
|
|
* @param value The body of the header.
|
|
|
|
*/
|
2006-04-20 07:36:50 +04:00
|
|
|
void setRequestHeader(in string header, in string value);
|
|
|
|
};
|
|
|
|
|
2006-04-20 07:37:23 +04:00
|
|
|
|
|
|
|
[scriptable, uuid(9deabc90-28d5-41d3-a660-474f2254f4ba)]
|
|
|
|
interface nsIJSXMLHttpRequest : nsISupports {
|
|
|
|
/**
|
|
|
|
* Meant to be a script-only mechanism for setting a load event listener.
|
|
|
|
* The attribute is expected to be JavaScript function object. When
|
|
|
|
* the load event occurs, the function is invoked.
|
|
|
|
* This attribute should not be used from native code!!
|
|
|
|
*/
|
|
|
|
attribute nsIDOMEventListener onload;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Meant to be a script-only mechanism for setting an error event listener.
|
|
|
|
* The attribute is expected to be JavaScript function object. When
|
|
|
|
* the error event occurs, the function is invoked.
|
|
|
|
* This attribute should not be used from native code!!
|
|
|
|
*/
|
|
|
|
attribute nsIDOMEventListener onerror;
|
|
|
|
};
|
|
|
|
|
2006-04-20 07:36:50 +04:00
|
|
|
%{ C++
|
|
|
|
#define NS_XMLHTTPREQUEST_CID \
|
|
|
|
{ /* d164e770-4157-11d4-9a42-000064657374 */ \
|
|
|
|
0xd164e770, 0x4157, 0x11d4, \
|
|
|
|
{0x9a, 0x42, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} }
|
2006-04-20 07:37:00 +04:00
|
|
|
#define NS_XMLHTTPREQUEST_CONTRACTID \
|
|
|
|
"@mozilla.org/xmlextras/xmlhttprequest;1"
|
2006-04-20 07:36:50 +04:00
|
|
|
%}
|