FetchResponse
Fetch: Response.
Describes the structure of an HTTP response provided via the Fetch sub-system, which implements the WhatWG Fetch API Standard, in both browser JavaScript engines and server-side JavaScript engines. The Fetch system and specification are designed to make HTTP data fetches easy in JavaScript environments, and stand as a modern replacement for the famous XMLHttpRequest
API in browsers, and the http
/https
layers in NodeJS.
Fetch responses model normal HTTP response structures, including a status code/status text, response headers, and a response body, as applicable. Not all HTTP responses carry a response body. Responses can be used to model content originating from a guest VM script (in the case of a generated or synthesized response, potentially in response to input, such as an HTTP request), or used to model a response to originated requests, for example, when fetching data from inside a VM and accessing the resulting response.
From MDN: "The Response interface of the Fetch API represents the response to a request. You can create a new Response object using the Response() constructor, but you are more likely to encounter a Response object being returned as the result of another API operation—for example, a service worker FetchEvent.respondWith, or a simple fetch()."
Use as execution output
The FetchResponse interface is used, along with the FetchRequest interface, to model server-style invocation for the JavaScript VM. In this case, a FetchResponse instance is expected as the output for a VM execution run, which is seeded with a FetchRequest instance provided by the outer host server runtime.
Multiple concrete FetchResponse implementations exist; each originate from a given server implementation.
Use from a guest context
Responses can be created from within a JavaScript guest, or received from within a guest context when executing a fetched FetchRequest (host permissions permitting).
Inheritors
Types
Default values applied to FetchResponse interfaces.
Describes the layout of constructors available to create new FetchResponse implementation objects, either via host-side code or, where supported, via guest-side code. Some of these constructors are driven by spec requirements whereas others are provided for host-side convenience. See individual constructor docs for more details.
Properties
Provides access to a ReadableStream which expresses body data enclosed with this response, as applicable and where supported; if no stream can be produced for this response, null
may be returned.
Indicates whether the ReadableStream provided by body has been consumed for this request.
Provides a typed view of headers associated with this HTTP response, via FetchHeaders, which behaves as a specialized JavaScript-compatible multi-map. Multiple header values can be expressed per header key, if desired, which can be safely combined into a comma-separated header value group upon render.
Indicates whether this response was redirected.
Provides the terminal HTTP status text which corresponds with the terminal status code for this response.