Skip to content

Commit

Permalink
only enable Z_SYNC_FLUSH for gzip response
Browse files Browse the repository at this point in the history
  • Loading branch information
David Frank committed May 15, 2017
1 parent 2a1a565 commit 770388d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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));
});
Expand Down

0 comments on commit 770388d

Please sign in to comment.