import { ReadableStream } from "web-streams-polyfill"; import { HttpBody } from "./request"; import { Headers, HeadersInit } from "./headers"; /** Initialization data for creating a new response. */ export interface ResponseInit { /** Any headers to pass to the client. */ headers?: HeadersInit; /** The response status code. */ status?: number; /** The status text to use. */ statusText?: string; } /** Represents an HTTP response. */ export declare class Response { #private; /** * Constructs a new HTTP response. * * @param body The HTTP response body. * @param init Response initialization metadata. */ constructor(body?: HttpBody | null, init?: ResponseInit); /** * Gets the body of the response as `ReadableStream`. * * This can only be called once. Subsequent accesses will throw a `TypeError`. */ get body(): ReadableStream | null; /** Returns whether the body has already been used and subsequent accesses would throw. */ get bodyUsed(): boolean; /** Gets the HTTP response headers. */ get headers(): Headers; /** * Returns whether the response's status code indicates success. * * Success is defined as HTTP status codes 200-299 (inclusive). */ get ok(): boolean; /** Returns whether the response was redirected. */ get redirected(): boolean; /** Returns the HTTP status code. */ get status(): number; /** Returns the status message corresponding to the status code. */ get statusText(): string; /** Gets the URL that was ultimately fetched (after redirects). */ get url(): string; /** * Returns a promise that resolves with the response data read into an ArrayBuffer. * * Be aware, this reads the entire response into memory, and thus may easily exceed * your heap limit. */ arrayBuffer(): Promise; /** Attempts to deserialize the response body as JSON. */ json(): Promise; /** Reads the response body to a string. The text is decoded using UTF-8. */ text(): Promise; }