A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.cloudflare.com/workers/runtime-apis/response below:

Response · Cloudflare Workers docs

The Response interface represents an HTTP response and is part of the Fetch API.

let response = new Response(body, init);

Valid options for the options object include:

Additional instance methods

Response implements the Body ↗ mixin of the Fetch API ↗, and therefore Response instances additionally have the following methods available:

The Content-Length header will be automatically set by the runtime based on whatever the data source for the Response is. Any value manually set by user code in the Headers will be ignored. To have a Content-Length header with a specific value specified, the body of the Response must be either a FixedLengthStream or a fixed-length value just as a string or TypedArray.

A FixedLengthStream is an identity TransformStream that permits only a fixed number of bytes to be written to it.

const { writable, readable } = new FixedLengthStream(11);

const enc = new TextEncoder();

const writer = writable.getWriter();

writer.write(enc.encode("hello world"));

writer.end();

return new Response(readable);

Using any other type of ReadableStream as the body of a response will result in chunked encoding being used.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4