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/.
6 * The origin of this IDL file is
7 * https://fetch.spec.whatwg.org/#response-class
10 [Exposed=(Window,Worker)]
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
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();
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;
35 NewObject] Response clone();
37 [ChromeOnly, NewObject, Throws] Response cloneUnfiltered();
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.
46 partial interface Response {
48 readonly attribute ReadableStream? body;
51 dictionary ResponseInit {
52 unsigned short status = 200;
53 ByteString statusText = "";
57 enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredirect" };