UNPKG

zents

Version:

ZenTS is a Node.js & TypeScript MVC-Framework for building rich web applications, released as free and open-source software under the MIT License. It is designed for building web applications with modern tools and design patterns.

67 lines 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ResponseHeader = void 0; const getContentType_1 = require("../utils/getContentType"); class ResponseHeader { constructor(res) { this.res = res; } all() { return this.res.getHeaders(); } get(key) { return this.res.getHeader(key); } has(key) { if (this.isSend()) { return false; } return this.res.hasHeader(key); } set(key, value) { if (this.isSend()) { return; } this.res.setHeader(key, value.toString()); } multiple(headers) { if (this.isSend()) { return; } for (const header of headers) { this.set(header.key, header.value); } } setContentType(filenameOrExt) { const type = getContentType_1.getContentType(filenameOrExt); if (!type) { return false; } this.set('Content-Type', filenameOrExt); return true; } getContentType() { const contentType = this.get('Content-Type'); if (typeof contentType !== 'string') { return null; } return contentType; } remove(key) { if (this.isSend()) { return; } this.res.removeHeader(key); } flush() { this.res.flushHeaders(); } keys() { return this.res.getHeaderNames(); } isSend() { return this.res.headersSent; } } exports.ResponseHeader = ResponseHeader; //# sourceMappingURL=ResponseHeader.js.map