rjweb-server
Version:
Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS
22 lines (21 loc) • 583 B
JavaScript
export 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;
}
}