fastify-compression
Advanced tools
Comparing version 0.4.1 to 0.4.2
17
index.js
@@ -13,12 +13,3 @@ 'use strict'; | ||
const supportedEncodings = ['gzip', 'deflate']; | ||
const compressionStreams = { | ||
gzip: zlib.createGzip, | ||
deflate: zlib.createDeflate | ||
} | ||
if (opts.brotli) { | ||
compressionStreams.br = opts.brotli; | ||
supportedEncodings.push('br'); | ||
} | ||
fastify.addHook('onSend', compression) | ||
@@ -39,3 +30,3 @@ | ||
reply.header('Content-Encoding', method); | ||
const compressionStream = compressionStreams[method](); | ||
const compressionStream = method === 'gzip' ? zlib.createGzip() : zlib.createDeflate(); | ||
@@ -57,3 +48,3 @@ pump(payloadStream, compressionStream, onEnd.bind(request)) | ||
function setVaryHeader(reply) { | ||
const varyHeader = reply.res.getHeader('Vary'); | ||
const varyHeader = reply._headers['vary']; | ||
reply.header('Vary', getVaryHeaderValue(varyHeader)); | ||
@@ -77,3 +68,3 @@ } | ||
function isCompressible(reply) { | ||
const contentType = reply.res.getHeader('Content-Type'); | ||
const contentType = reply._headers['content-type']; | ||
return contentType ? compressible(contentType) : true; | ||
@@ -83,3 +74,3 @@ } | ||
const metadata = { | ||
fastify: '>=0.43.0', | ||
fastify: '>=1.0.0-rc.3', | ||
name: 'fastify-compression' | ||
@@ -86,0 +77,0 @@ } |
{ | ||
"name": "fastify-compression", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "A compression plugin for fastify", | ||
@@ -36,4 +36,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"eslint": "^4.18.0", | ||
"fastify": "^1.0.0-rc.2", | ||
"eslint": "^4.18.2", | ||
"fastify": "^1.0.0-rc.3", | ||
"request": "^2.83.0", | ||
@@ -40,0 +40,0 @@ "tap": "^11.0.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18757
462