import { IncomingMessage } from "http"; import ServerRequestInterface from "./Contracts/ServerRequestInterface"; import MessageMixin from "./Minxins/MessageMixin"; import RequestMixin from "./Minxins/RequestMixin"; /** * 服务器收到的请求对象 */ declare class ServerRequest implements ServerRequestInterface { protected attributes: Record; protected cookieParams: Record; protected parsedBody: Record; protected queryParams: Record; protected serverParams: Record; protected uploadedFiles: Record; constructor(method: string, url: string, headers?: Record, body?: Buffer | Record | string, version?: string, serverParams?: Record); /** * 解析 body 内容 * 支持 JSON字符串、XML字符串、QueryString等格式 */ protected parseBody(): Promise; getServerParams(): Record; getCookieParams(): Record; withCookieParams(cookies: Record): this; getQueryParams(): Record; withQueryParams(query: Record): this; getUploadedFiles(): Record; withUploadedFiles(files: Record): this; getParsedBody(): Promise>; withParsedBody(data: Record): this; getAttributes(): Record; getAttribute(name: string, defaultValue?: any): any; withAttribute(name: string, value: any): this; withoutAttribute(name: string): this; /** * 通过 IncomingMessage 创建实例 * * 由于 IncomingMessage 的 body 流的特殊性,某些框架(目前已知:fastify) * 可能会自动读取后挂载到上下文中,从而导致 node-easywechat 去尝试读取时报错。 * 这时可以选择传入第二个参数,即 body 的内容 * * @param req * @param body 支持 Buffer、object对象、JSON字符串、XML字符串、QueryString格式的 body 内容字符串 * @returns */ static createFromIncomingMessage(req: IncomingMessage, body?: Buffer | Record | string): Promise; } interface ServerRequest extends MessageMixin, RequestMixin { } export = ServerRequest;