package org.w3c.fetch; // Downloaded from https://raw.githubusercontent.com/whatwg/fetch/master/Overview.src.html typedef (Headers or sequence> or OpenEndedDictionary) HeadersInit; [Constructor(optional HeadersInit init), Exposed=(Window,Worker)] interface Headers { void append(ByteString name, ByteString value); void delete(ByteString name); ByteString? get(ByteString name); boolean has(ByteString name); void set(ByteString name, ByteString value); iterable; }; typedef (Blob or BufferSource or FormData or URLSearchParams or USVString) BodyInit; typedef (BodyInit or ReadableStream) ResponseBodyInit; [NoInterfaceObject, Exposed=(Window,Worker)] interface Body { readonly attribute boolean bodyUsed; [NewObject] Promise arrayBuffer(); [NewObject] Promise blob(); [NewObject] Promise formData(); [NewObject] Promise json(); [NewObject] Promise text(); }; typedef (Request or USVString) RequestInfo; [Constructor(RequestInfo input, optional RequestInit init), Exposed=(Window,Worker)] interface Request { readonly attribute ByteString method; readonly attribute USVString url; [SameObject] readonly attribute Headers headers; readonly attribute RequestType type; readonly attribute RequestDestination destination; readonly attribute USVString referrer; readonly attribute ReferrerPolicy referrerPolicy; readonly attribute RequestMode mode; readonly attribute RequestCredentials credentials; readonly attribute RequestCache cache; readonly attribute RequestRedirect redirect; readonly attribute DOMString integrity; readonly attribute boolean keepalive; [NewObject] Request clone(); }; Request implements Body; dictionary RequestInit { ByteString method; HeadersInit headers; BodyInit? body; USVString referrer; ReferrerPolicy referrerPolicy; RequestMode mode; RequestCredentials credentials; RequestCache cache; RequestRedirect redirect; DOMString integrity; boolean keepalive; any window; // can only be set to null }; enum RequestType { "", "audio", "font", "image", "script", "style", "track", "video" }; enum RequestDestination { "", "document", "embed", "font", "image", "manifest", "media", "object", "report", "script", "serviceworker", "sharedworker", "style", "worker", "xslt" }; enum RequestMode { "navigate", "same-origin", "no-cors", "cors" }; enum RequestCredentials { "omit", "same-origin", "include" }; enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" }; enum RequestRedirect { "follow", "error", "manual" }; [Constructor(optional ResponseBodyInit? body = null, optional ResponseInit init), Exposed=(Window,Worker)] interface Response { [NewObject] static Response error(); [NewObject] static Response redirect(USVString url, optional unsigned short status = 302); readonly attribute ResponseType type; readonly attribute USVString url; readonly attribute boolean redirected; readonly attribute unsigned short status; readonly attribute boolean ok; readonly attribute ByteString statusText; [SameObject] readonly attribute Headers headers; readonly attribute ReadableStream? body; [SameObject] readonly attribute Promise trailer; [NewObject] Response clone(); }; Response implements Body; dictionary ResponseInit { unsigned short status = 200; ByteString statusText = "OK"; HeadersInit headers; }; enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredirect" }; partial interface WindowOrWorkerGlobalScope { [NewObject] Promise fetch(RequestInfo input, optional RequestInit init); };