/// import { EventEmitter } from "events"; import * as T from "./_types"; import { IncomingMessage } from "./incoming-message"; export declare class ServerResponse extends EventEmitter { socket: T.Socket; connection: T.Socket; statusCode: number; statusMessage?: string; sendDate: boolean; finished: boolean; headersSent: boolean; /** * @description * Emulates nodes ServerResponse in the browser. * See: https://nodejs.org/api/http.html#http_class_http_serverresponse * * @param incomingMessage The incoming message that is tied to the response. */ constructor(incomingMessage: IncomingMessage); /** * @description * This is a noop in the browser. */ writeContinue(): void; /** * @description * This is a noop in the browser. */ setTimeout(): void; /** * @description * This is a noop in the browser. */ addTrailers(): void; /** * @description * Writes data to the current ServerResponse body. * * @example * res.write("Hello World") * * @param chunk A chunk to write to the server response. * @param encoding The encoding to use for the chunk (does nothing in browser). * @param onFinish A function called when the chunk has been written out. */ write(chunk: T.Chunk, encoding?: string | T.EmptyCallback, onFinish?: T.EmptyCallback): void; /** * @description * Write status, status message and headers to the current ServerResponse. * * @example * res.writeHead(200, "OK", { "Content-Type": "text/html" }) * * @param statusCode The status code to write. * @param statusMessage The status message to write. * @param headers An object containing headers to write. */ writeHead(statusCode: number, statusMessage?: string | T.Headers, headers?: T.Headers): void; /** * @description * Get a shallow copy of all response header names. * * @example * res.getHeaders() // { "Content-Type": "...", ... } */ getHeaders(): T.Headers; /** * @description * Get a list of current header names. * * @example * res.getHeaderNames() // ["Content-Type", ...] */ getHeaderNames(): string[]; /** * @description * Get a header from the current ServerResponse. * * @example * res.getHeader("Content-Type") // "text/html" * * @param header The name of the header to get. */ getHeader(header: string): string[] | string | void; /** * @description * Check if a header has been set. * * @example * res.hasHeader("Content-Type") // true * * @param header The name of the header to check. */ hasHeader(header: string): boolean; /** * @description * Remove a header from the current ServerResponse. * * @example * res.removeHeader("Content-Type") * * res.hasHeader("Content-Type") // false * * @param header The name of the header to remove. */ removeHeader(header: string): void; /** * @description * Write a header to the current ServerResponse. * * @example * res.setHeader("Content-Type", "text/html") * * res.hasHeader("Content-Type") // true * * @param header The name of the header to set. * @param value The value to set the header. */ setHeader(header: string, value: string | string[]): void; /** * @description * Handle event ending from the current ServerResponse. * * @example * res.end("Hello World") * * @param chunk An option final chunk to write. * @param encoding The encoding for the optional chunk. * @param onFinish A function called when the response has been sent. */ end(chunk?: T.Chunk | T.EmptyCallback, encoding?: string | T.EmptyCallback, onFinish?: T.EmptyCallback): void; }