Bug 422974 ? Prism uses old "Remember password?" mechanism. r=gavin
[wine-gecko.git] / content / base / public / nsIXMLHttpRequest.idl
blob37b6b7c7cd4fbe008fcbf29eee7f0e537566aa5d
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #include "nsISupports.idl"
40 interface nsIChannel;
41 interface nsIDOMDocument;
42 interface nsIDOMEventListener;
43 interface nsIPrincipal;
44 interface nsIScriptContext;
45 interface nsIVariant;
46 interface nsPIDOMWindow;
48 /**
49 * Mozilla's XMLHttpRequest is modelled after Microsoft's IXMLHttpRequest
50 * object. The goal has been to make Mozilla's version match Microsoft's
51 * version as closely as possible, but there are bound to be some differences.
53 * In general, Microsoft's documentation for IXMLHttpRequest can be used.
54 * Mozilla's interface definitions provide some additional documentation. The
55 * web page to look at is http://www.mozilla.org/xmlextras/
57 * Mozilla's XMLHttpRequest object can be created in JavaScript like this:
58 * new XMLHttpRequest()
59 * compare to Internet Explorer:
60 * new ActiveXObject("Msxml2.XMLHTTP")
62 * From JavaScript, the methods and properties visible in the XMLHttpRequest
63 * object are a combination of nsIXMLHttpRequest and nsIJSXMLHttpRequest;
64 * there is no need to differentiate between those interfaces.
66 * From native code, the way to set up onload and onerror handlers is a bit
67 * different. Here is a comment from Johnny Stenback <jst@netscape.com>:
69 * The mozilla implementation of nsIXMLHttpRequest implements the interface
70 * nsIDOMEventTarget and that's how you're supported to add event listeners.
71 * Try something like this:
73 * nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(myxmlhttpreq));
75 * target->AddEventListener(NS_LITERAL_STRING("load"), mylistener,
76 * PR_FALSE)
78 * where mylistener is your event listener object that implements the
79 * interface nsIDOMEventListener.
81 * The 'onload', 'onerror', and 'onreadystatechange' attributes moved to
82 * nsIJSXMLHttpRequest, but if you're coding in C++ you should avoid using
83 * those.
85 * Though actually, if you use addEventListener from C++ weird things will
86 * happen too, since the result will depend on what JS happens to be on the
87 * stack when you do it....
89 * Conclusion: Do not use event listeners on XMLHttpRequest from C++, unless
90 * you're aware of all the security implications. And then think twice about
91 * it.
93 [scriptable, uuid(acda85ab-d06c-4176-b834-6d129ca97ca3)]
94 interface nsIXMLHttpRequest : nsISupports
96 /**
97 * The request uses a channel in order to perform the
98 * request. This attribute represents the channel used
99 * for the request. NULL if the channel has not yet been
100 * created.
102 * In a multipart request case, this is the initial channel, not the
103 * different parts in the multipart request.
105 * Mozilla only. Requires elevated privileges to access.
107 readonly attribute nsIChannel channel;
110 * The response to the request is parsed as if it were a
111 * text/xml stream. This attributes represents the response as
112 * a DOM Document object. NULL if the request is unsuccessful or
113 * has not yet been sent.
115 readonly attribute nsIDOMDocument responseXML;
118 * The response to the request as text.
119 * NULL if the request is unsuccessful or
120 * has not yet been sent.
122 readonly attribute AString responseText;
126 * The status of the response to the request for HTTP requests.
128 readonly attribute unsigned long status;
131 * The string representing the status of the response for
132 * HTTP requests.
134 readonly attribute AUTF8String statusText;
137 * If the request has been sent already, this method will
138 * abort the request.
140 void abort();
143 * Returns all of the response headers as a string for HTTP
144 * requests.
146 * Note that this will return all the headers from the *current*
147 * part of a multipart request, not from the original channel.
149 * @returns A string containing all of the response headers.
150 * NULL if the response has not yet been received.
152 string getAllResponseHeaders();
155 * Returns the text of the header with the specified name for
156 * HTTP requests.
158 * @param header The name of the header to retrieve
159 * @returns A string containing the text of the header specified.
160 * NULL if the response has not yet been received or the
161 * header does not exist in the response.
163 ACString getResponseHeader(in AUTF8String header);
166 * Native (non-script) method to initialize a request. Note that
167 * the request is not sent until the <code>send</code> method
168 * is invoked.
170 * If there is an "active" request (that is, if open() or openRequest() has
171 * been called already), this is equivalent to calling abort().
173 * @param method The HTTP method, for example "POST" or "GET". Ignored
174 * if the URL is not a HTTP(S) URL.
175 * @param url The URL to which to send the request.
176 * @param async Whether the request is synchronous or asynchronous
177 * i.e. whether send returns only after the response
178 * is received or if it returns immediately after
179 * sending the request. In the latter case, notification
180 * of completion is sent through the event listeners.
181 * This argument must be true if the multipart
182 * attribute has been set to true, or an exception will
183 * be thrown.
184 * @param user A username for authentication if necessary.
185 * @param password A password for authentication if necessary.
187 [noscript] void openRequest(in AUTF8String method,
188 in AUTF8String url,
189 in boolean async,
190 in AString user,
191 in AString password);
194 * Meant to be a script-only method for initializing a request.
195 * The parameters are similar to the ones detailed in the
196 * description of <code>openRequest</code>, but the last
197 * 3 are optional.
199 * If there is an "active" request (that is, if open() or openRequest() has
200 * been called already), this is equivalent to calling abort().
202 * @param method The HTTP method - either "POST" or "GET". Ignored
203 * if the URL is not a HTTP URL.
204 * @param url The URL to which to send the request.
205 * @param async (optional) Whether the request is synchronous or
206 * asynchronous i.e. whether send returns only after
207 * the response is received or if it returns immediately after
208 * sending the request. In the latter case, notification
209 * of completion is sent through the event listeners.
210 * The default value is true.
211 * This argument must be true if the multipart
212 * attribute has been set to true, or an exception will
213 * be thrown.
214 * @param user (optional) A username for authentication if necessary.
215 * The default value is the empty string
216 * @param password (optional) A password for authentication if necessary.
217 * The default value is the empty string
219 void open(in AUTF8String method, in AUTF8String url);
222 * Sends the request. If the request is asynchronous, returns
223 * immediately after sending the request. If it is synchronous
224 * returns only after the response has been received.
226 * All event listeners must be set before calling send().
228 * After the initial response, all event listeners will be cleared.
229 * // XXXbz what does that mean, exactly?
231 * @param body Either an instance of nsIDOMDocument, nsIInputStream
232 * or a string (nsISupportsString in the native calling
233 * case). This is used to populate the body of the
234 * HTTP request if the HTTP request method is "POST".
235 * If the parameter is a nsIDOMDocument, it is serialized.
236 * If the parameter is a nsIInputStream, then it must be
237 * compatible with nsIUploadChannel.setUploadStream, and a
238 * Content-Length header will be added to the HTTP request
239 * with a value given by nsIInputStream.available. Any
240 * headers included at the top of the stream will be
241 * treated as part of the message body. The MIME type of
242 * the stream should be specified by setting the Content-
243 * Type header via the setRequestHeader method before
244 * calling send.
246 void send([optional] in nsIVariant body);
249 * A variant of the send() method used to send binary data.
251 * @param body The request body as a DOM string. The string data will be
252 * converted to a single-byte string by truncation (i.e., the
253 * high-order byte of each character will be discarded).
255 void sendAsBinary(in DOMString body);
258 * Sets a HTTP request header for HTTP requests. You must call open
259 * before setting the request headers.
261 * @param header The name of the header to set in the request.
262 * @param value The body of the header.
264 void setRequestHeader(in AUTF8String header, in AUTF8String value);
267 * The state of the request.
269 * Possible values:
270 * 0 UNINITIALIZED open() has not been called yet.
271 * 1 LOADING send() has not been called yet.
272 * 2 LOADED send() has been called, headers and status are available.
273 * 3 INTERACTIVE Downloading, responseText holds the partial data.
274 * 4 COMPLETED Finished with all operations.
276 readonly attribute long readyState;
279 * Override the mime type returned by the server (if any). This may
280 * be used, for example, to force a stream to be treated and parsed
281 * as text/xml, even if the server does not report it as such. This
282 * must be done before the <code>send</code> method is invoked.
284 * @param mimetype The type used to override that returned by the server
285 * (if any).
287 void overrideMimeType(in AUTF8String mimetype);
290 * Set to true if the response is expected to be a stream of
291 * possibly multiple (XML) documents. If set to true, the content
292 * type of the initial response must be multipart/x-mixed-replace or
293 * an error will be triggerd. All requests must be asynchronous.
295 * This enables server push. For each XML document that's written to
296 * this request, a new XML DOM document is created and the onload
297 * handler is called inbetween documents. Note that when this is
298 * set, the onload handler and other event handlers are not reset
299 * after the first XML document is loaded, and the onload handler
300 * will be called as each part of the response is received.
302 attribute boolean multipart;
305 * Set to true if this is a background service request. This will
306 * prevent a load group being associated with the request, and
307 * suppress any security dialogs from being shown * to the user.
308 * In the cases where one of those dialogs would be shown, the request
309 * will simply fail instead.
311 attribute boolean mozBackgroundRequest;
314 * Initialize the object for use from C++ code with the principal, script
315 * context, and owner window that should be used.
317 * @param principal The principal to use for the request. This must not be
318 * null.
319 * @param scriptContext The script context to use for the request. May be
320 * null.
321 * @param ownerWindow The associated window for the request. May be null.
323 [noscript] void init(in nsIPrincipal principal,
324 in nsIScriptContext scriptContext,
325 in nsPIDOMWindow ownerWindow);
328 [scriptable, uuid(261676b4-d508-43bf-b099-74635a0ee2e9)]
329 interface nsIJSXMLHttpRequest : nsISupports {
331 * Meant to be a script-only mechanism for setting a load event listener.
332 * The attribute is expected to be JavaScript function object. When
333 * the load event occurs, the function is invoked.
334 * This attribute should not be used from native code!!
336 * After the initial response, all event listeners will be cleared.
337 * // XXXbz what does that mean, exactly?
339 * Call open() before setting an onload listener.
341 * Mozilla only.
343 attribute nsIDOMEventListener onload;
346 * Meant to be a script-only mechanism for setting an error event listener.
347 * The attribute is expected to be JavaScript function object. When
348 * the error event occurs, the function is invoked.
349 * This attribute should not be used from native code!!
351 * After the initial response, all event listeners will be cleared.
352 * // XXXbz what does that mean, exactly?
354 * Call open() before setting an onerror listener.
356 * Mozilla only.
358 attribute nsIDOMEventListener onerror;
361 * Meant to be a script-only mechanism for setting a progress event listener.
362 * The attribute is expected to be JavaScript function object. When
363 * the error event occurs, the function is invoked.
364 * This attribute should not be used from native code!!
365 * This event listener may be called multiple times during the open request.
367 * After the initial response, all event listeners will be cleared.
368 * // XXXbz what does that mean, exactly?
370 * This event listener must be set BEFORE calling open().
372 * Mozilla only.
374 attribute nsIDOMEventListener onprogress;
377 * Meant to be a script-only mechanism for setting an upload progress event
378 * listener.
379 * This attribute should not be used from native code!!
380 * This event listener may be called multiple times during the upload..
382 * After the initial response, all event listeners will be cleared.
383 * // XXXbz what does that mean, exactly?
385 * This event listener must be set BEFORE calling open().
387 * Mozilla only.
389 attribute nsIDOMEventListener onuploadprogress;
392 * Meant to be a script-only mechanism for setting a callback function.
393 * The attribute is expected to be JavaScript function object. When the
394 * readyState changes, the callback function will be called.
395 * This attribute should not be used from native code!!
397 * After the initial response, all event listeners will be cleared.
398 * // XXXbz what does that mean, exactly?
400 * Call open() before setting an onreadystatechange listener.
402 attribute nsIDOMEventListener onreadystatechange;
405 %{ C++
406 #define NS_XMLHTTPREQUEST_CID \
407 { /* d164e770-4157-11d4-9a42-000064657374 */ \
408 0xd164e770, 0x4157, 0x11d4, \
409 {0x9a, 0x42, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} }
410 #define NS_XMLHTTPREQUEST_CONTRACTID \
411 "@mozilla.org/xmlextras/xmlhttprequest;1"