UNPKG

rjweb-server

Version:

Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS

26 lines (25 loc) 718 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HttpContext = void 0; class HttpContext { constructor() { this.compression = null; } compress(algorithm) { this.compression = algorithm; return this; } getCompression() { return this.compression; } compressionHeader(chunked) { if (this.compression) { if (chunked) this.header('transfer-encoding', 'chunked'); this.header('content-encoding', this.compression === 'brotli' ? 'br' : this.compression); this.header('vary', 'Accept-Encoding'); } return this; } } exports.HttpContext = HttpContext;