@dazejs/framework
Version:
Daze.js - A powerful web framework for Node.js
63 lines (62 loc) • 2.4 kB
TypeScript
/// <reference types="node" />
import { OutgoingHttpHeaders, ServerResponse } from 'http';
import { Cookie } from '../cookie';
import { Application } from '../../foundation/application';
import { Request } from '../request';
import { Statusable } from './statusable';
export declare class Response extends Statusable {
protected app: Application;
protected _code: number;
protected _header: OutgoingHttpHeaders;
protected _data: any;
protected cookies: Cookie[];
protected _isForce: boolean;
protected _needEncrypt: boolean;
constructor(data?: any, code?: number, header?: OutgoingHttpHeaders);
set code(code: number);
get code(): number;
set data(data: any);
get data(): any;
force(): this;
isForce(): boolean;
private parseHeaders;
error(message: any, code?: number): this;
success(data: any, code?: number): this;
getHeader(name: string): string | number | string[] | undefined;
setHeader(name: any, value: any): this;
removeHeader(name: any): this;
getHeaders(): OutgoingHttpHeaders;
setHeaders(headers: any): this;
getCode(): number;
getStatus(): number;
setCode(code?: number): this;
setStatus(code: number): this;
getData(): any;
setType(type: string): this;
getType(): string;
setLength(length: number): this;
getLength(): number;
setVary(field: string): void;
lastModified(time: string | Date | number): this;
expires(time: string): this;
eTag(eTag: string): this;
cacheControl(cache: string): this;
noCache(): this;
contentType(contentType: string, charset?: string): this;
attachment(filename: string | undefined, options: any): this;
download(data: any, filename: string | undefined, options: any): this;
transformData(request: any): any;
withCookie(_cookie: any): this;
cookie(key: string, value: any, options?: any): this;
json(data?: any): this;
html(data?: any): this;
text(data?: any): this;
commitCookies(request: any): Promise<void>;
sendHeaders(res: ServerResponse): this;
setData(data: any): this;
encrypt(encrypt?: boolean): this;
prepare(request: Request): any;
send(request: Request): Promise<void | ServerResponse>;
end(request: Request, data: any): Promise<void | ServerResponse>;
endWithCompress(request: Request, data: any): Promise<void | ServerResponse>;
}