/** * This module was for the most part based on the code of cfworker's RequestBuilder * https://github.com/cfworker/cfworker/blob/master/packages/web/src/response-builder.ts * * The main differences: * - No magic static setting * - No magic statusText handling * - Removed etag, lastModified, type helpers, instead added 'set' and 'get' shorthands. * * (MIT Licensed) */ /// import { HeadersShorthands } from "../context"; import { RedirectStatus } from "../status"; /** * The different types that can be sniffed and converted to a valid body automatically. */ export declare type ExtendedBodyInit = BodyInit | boolean | Date | number | object | undefined | null; /** * The data that will be used as the response for the request. */ export declare class ResponseData implements ResponseInit, HeadersShorthands { headers: Headers; status?: number; statusText?: string; /** * Cloudflare Worker websocket, non-standard API */ webSocket?: WebSocket | null; private _implicitType; private _stringifyBody; private _body; get body(): ExtendedBodyInit; set body(value: ExtendedBodyInit); set(name: string, value: string): void; get(name: string): string | null; has(name: string): boolean; /** * Sets the headers to a redirect header (`location`) with given status. * @param url * @param status Status of redirect, default to Status Found (302). */ redirect(url: string | URL, status?: RedirectStatus): void; /** * Overwrite the response with given response, useful when you are passing on a request from a Durable Object * or some other fetch request. * * @param response Response that will overwrite the response being constructed so far. * @param opts You can set the option to `mergeHeaders` here, which keeps existing headers unless they are * overwritten. This is useful when you have middleware that set specific headers (such as CORS) * which you don't want to drop. */ overwrite(response: Response, opts?: { mergeHeaders?: boolean; }): void; /** * Create a native Response object, which is what FetchEvent expectst */ createResponse(): Response; }