Merge pull request #275 from bitinn/v2-alpha-4

2.0.0 alpha 4
This commit is contained in:
David Frank 2017-05-15 20:09:24 +08:00 committed by GitHub
commit 9cea8719eb
2 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "node-fetch",
"version": "2.0.0-alpha.3",
"version": "2.0.0-alpha.4",
"description": "A light-weight module that brings window.fetch to node.js",
"main": "lib/index.js",
"browser": "./browser.js",

View File

@ -141,6 +141,7 @@ export default function fetch(url, opts) {
return;
}
// For Node v6+
// Be less strict when decoding compressed responses, since sometimes
// servers send slightly invalid responses that are still accepted
// by common browsers.
@ -165,9 +166,9 @@ export default function fetch(url, opts) {
raw.once('data', chunk => {
// see http://stackoverflow.com/questions/37519828
if ((chunk[0] & 0x0F) === 0x08) {
body = body.pipe(zlib.createInflate(zlibOptions));
body = body.pipe(zlib.createInflate());
} else {
body = body.pipe(zlib.createInflateRaw(zlibOptions));
body = body.pipe(zlib.createInflateRaw());
}
resolve(new Response(body, response_options));
});