Socket
Socket
Sign inDemoInstall

decompress-response

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decompress-response - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

43

index.js
'use strict';
const PassThrough = require('stream').PassThrough;
const zlib = require('zlib');
const mimicResponse = require('mimic-response');
// We define these manually to ensure they're always copied
// even if they would move up the prototype chain
// https://nodejs.org/api/http.html#http_class_http_incomingmessage
const knownProps = [
'destroy',
'setTimeout',
'socket',
'headers',
'trailers',
'rawHeaders',
'statusCode',
'httpVersion',
'httpVersionMinor',
'httpVersionMajor',
'rawTrailers',
'statusMessage'
];
const copyProps = (fromStream, toStream) => {
const toProps = Object.keys(toStream);
const fromProps = new Set(Object.keys(fromStream).concat(knownProps));
for (const prop of fromProps) {
// Don't overwrite existing properties
if (toProps.indexOf(prop) !== -1) {
continue;
}
toStream[prop] = typeof prop === 'function' ? fromStream[prop].bind(fromStream) : fromStream[prop];
}
};
module.exports = res => {
module.exports = response => {
// TODO: Use Array#includes when targeting Node.js 6
if (['gzip', 'deflate'].indexOf(res.headers['content-encoding']) === -1) {
return res;
if (['gzip', 'deflate'].indexOf(response.headers['content-encoding']) === -1) {
return response;
}

@@ -46,3 +15,3 @@

copyProps(res, stream);
mimicResponse(response, stream);

@@ -58,5 +27,5 @@ unzip.on('error', err => {

res.pipe(unzip).pipe(stream);
response.pipe(unzip).pipe(stream);
return stream;
};

8

package.json
{
"name": "decompress-response",
"version": "3.2.0",
"version": "3.3.0",
"description": "Decompress a HTTP response if needed",

@@ -44,9 +44,11 @@ "license": "MIT",

],
"dependencies": {
"mimic-response": "^1.0.0"
},
"devDependencies": {
"ava": "*",
"get-stream": "^3.0.0",
"pify": "^2.3.0",
"rfpify": "^1.0.0",
"pify": "^3.0.0",
"xo": "*"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc