/// import { ServerResponse } from "http"; import { Context } from "./context"; import * as cookie from "cookie"; export interface CookieOptions extends cookie.CookieSerializeOptions { /** 是否签名 */ signed?: boolean; } export declare class Response { readonly res: ServerResponse; readonly ctx: Context; constructor(res: ServerResponse, ctx: Context); /** * 初始化完成 */ inited(): void; /** * 设置响应状态码 * * @param statusCode 响应状态码 */ setStatus(statusCode: number): this; /** * 获取响应头 * * @param name 名称 */ getHeader(name: string): string | string[] | number; /** * 获取所有响应头 * * @param name 名称 */ getHeaders(): Record; /** * 设置响应头 * * @param name 名称 * @param value 值 */ setHeader(name: string, value: string | string[] | number): this; /** * 添加响应头 * * @param name 名称 * @param value 值 */ appendHeader(name: string, value: string | string[] | number): this; /** * 设置响应头 * * @param headers 响应头 */ setHeaders(headers: Record): this; /** * 删除响应头 * * @param name 名称 */ removeHeader(name: string): this; /** * 写响应头 * * @param statusCode 响应状态码 * @param headers 响应头 */ writeHead(statusCode: number, headers: Record): this; /** * 输出数据 * * @param data 要输出的数据 * @param encoding 字符编码 * @param callback 回调函数 */ write(data: string | Buffer | Uint8Array, encoding?: string, callback?: () => void): boolean; /** * 输出数据并结束 * * @param data 要输出的数据 * @param encoding 字符编码 * @param callback 回调函数 */ end(data: string | Buffer | Uint8Array, encoding?: string, callback?: () => void): boolean; /** * 响应JSON * @param data 数据 */ json(data: any): void; /** * 响应HTML页面 * @param str 内容 */ html(str: Buffer | string): void; /** * 删除Cookie * @param name 名称 * @param options 选项 */ clearCookie(name: string, options?: CookieOptions): void; /** * 设置Cookie * @param name 名称 * @param value 值 * @param options 选项 */ cookie(name: string, value: any, options?: CookieOptions): void; }