Bug 1879816: Make nsCocoaWindow::Destroy close the window and let destruction happen...
[gecko.git] / dom / webidl / Response.webidl
blobd04453c37c8b8f314de5fb09cf24e1cc0616e606
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4  * You can obtain one at http://mozilla.org/MPL/2.0/.
5  *
6  * The origin of this IDL file is
7  * https://fetch.spec.whatwg.org/#response-class
8  */
10 [Exposed=(Window,Worker)]
11 interface Response {
12   // This should be constructor(optional BodyInit... but BodyInit doesn't
13   // include ReadableStream yet because we don't want to expose Streams API to
14   // Request.
15   [Throws]
16   constructor(optional (Blob or BufferSource or FormData or URLSearchParams or ReadableStream or USVString)? body = null,
17               optional ResponseInit init = {});
19   [NewObject] static Response error();
20   [Throws,
21    NewObject] static Response redirect(USVString url, optional unsigned short status = 302);
22   [BinaryName=CreateFromJson, Throws,
23    NewObject] static Response json(any data, optional ResponseInit init = {});
25   readonly attribute ResponseType type;
27   readonly attribute USVString url;
28   readonly attribute boolean redirected;
29   readonly attribute unsigned short status;
30   readonly attribute boolean ok;
31   readonly attribute ByteString statusText;
32   [SameObject, BinaryName="headers_"] readonly attribute Headers headers;
34   [Throws,
35    NewObject] Response clone();
37   [ChromeOnly, NewObject, Throws] Response cloneUnfiltered();
39   // For testing only.
40   [ChromeOnly] readonly attribute boolean hasCacheInfoChannel;
42 Response includes Body;
44 // This should be part of Body but we don't want to expose body to request yet.
45 // See bug 1387483.
46 partial interface Response {
47   [GetterThrows]
48   readonly attribute ReadableStream? body;
51 dictionary ResponseInit {
52   unsigned short status = 200;
53   ByteString statusText = "";
54   HeadersInit headers;
57 enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredirect" };