Beta 7 with some repo names changed.
This commit is contained in:
1 parent
0f7b40cca7
commit
963c19493a
3408 files changed
+462217
-15516
No files matched your search
+29
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
const PassThrough = require('stream').PassThrough;
|
||||
const zlib = require('zlib');
|
||||
const mimicResponse = require('mimic-response');
|
||||
|
||||
module.exports = response => {
|
||||
// TODO: Use Array#includes when targeting Node.js 6
|
||||
if (['gzip', 'deflate'].indexOf(response.headers['content-encoding']) === -1) {
|
||||
return response;
|
||||
}
|
||||
|
||||
const unzip = zlib.createUnzip();
|
||||
const stream = new PassThrough();
|
||||
|
||||
mimicResponse(response, stream);
|
||||
|
||||
unzip.on('error', err => {
|
||||
if (err.code === 'Z_BUF_ERROR') {
|
||||
stream.end();
|
||||
return;
|
||||
}
|
||||
|
||||
stream.emit('error', err);
|
||||
});
|
||||
|
||||
response.pipe(unzip).pipe(stream);
|
||||
|
||||
return stream;
|
||||
};
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "decompress-response",
|
||||
"version": "3.3.0",
|
||||
"description": "Decompress a HTTP response if needed",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/decompress-response",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
{
|
||||
"name": "Vsevolod Strukchinsky",
|
||||
"email": "floatdrop@gmail.com",
|
||||
"url": "github.com/floatdrop"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"decompress",
|
||||
"response",
|
||||
"http",
|
||||
"https",
|
||||
"zlib",
|
||||
"gzip",
|
||||
"zip",
|
||||
"deflate",
|
||||
"unzip",
|
||||
"ungzip",
|
||||
"incoming",
|
||||
"message",
|
||||
"stream",
|
||||
"compressed"
|
||||
],
|
||||
"dependencies": {
|
||||
"mimic-response": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"get-stream": "^3.0.0",
|
||||
"pify": "^3.0.0",
|
||||
"xo": "*"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz"
|
||||
,"_integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M="
|
||||
,"_from": "decompress-response@^3.3.0"
|
||||
}
|
||||
Reference in new issue
Block a user