UNPKG

node-web-mvc

Version:
120 lines (119 loc) 2.88 kB
import { IncomingMessage, IncomingHttpHeaders } from 'http'; import MediaType from './MediaType'; import HttpMethod from './HttpMethod'; import ServletContext from './ServletContext'; import { IRequestBodyReader } from './body/IRequestBodyReader'; import { RequestDispatcher } from './RequestDispatcher'; type CreateDispatcherHandler = (path: string) => RequestDispatcher; declare class URLQuery { [propName: string]: any; } declare class Cookies { [propName: string]: string | Array<string>; } export default class HttpServletRequest { private _cookies; private readonly request; get cookies(): Cookies; /** * 当前请求上下文 */ get servletContext(): ServletContext; /** * 获取当前node原生请求对象 */ get nativeRequest(): IncomingMessage; /** * 获取完整协议域名 */ get fdomain(): string; /** * 获取完整的url */ get url(): string; /** * 获取当前请求完整path 不包含参数 */ get baseUrl(): string; get requestUrl(): string; private params; /** * 设置属性值 * @param name 属性名 * @param value 属性值 */ setAttribute(name: any, value: any): void; /** * 获取属性值 * @param name 属性名称 */ getAttribute<T = any>(name: any): T; /** * 请求参数 */ query: URLQuery; /** * 当前客户端请求域名 */ host: string; /** * 请求谓词 */ method: HttpMethod; /** * 当前请求端口 */ port: string; /** * 当前请求路径 */ path: string; /** * 当前请求协议 */ protocol: string; /** * 当前内容类型 */ mediaType: MediaType; /** * 当前pathVariables */ pathVariables: any; /** * 请求头信息 */ headers: IncomingHttpHeaders; bodyReader: IRequestBodyReader; readonly contextPath: string; /** * 当前正在读取的body内容 */ body: any; /** * 将可读流输送传入写出流 */ pipe(writeStream: any, options?: any): void; /** * 判断是否存在body */ get hasBody(): boolean; constructor(request: IncomingMessage, contextPath: string, createDispatcher: CreateDispatcherHandler, reader: IRequestBodyReader); setServletContext(context: ServletContext): void; /** * 解析cookie * @param cookieStr */ private parseCookie; getHeader(name: string): string | string[]; getHeaderValue(name: string): string[]; getHeaderSingleValue(name: string): string; getDateHeader(name: any): number; getRequestDispatcher(path: string): RequestDispatcher; /** * 读取body内容为buffer * @returns */ readBodyAsBuffer(): Promise<Buffer>; } export {};