@whatwg-node/node-fetch
Advanced tools
Comparing version 0.3.1 to 0.3.2-rc-20230314154619-367ff2a
18
index.js
@@ -12,2 +12,3 @@ 'use strict'; | ||
const url = require('url'); | ||
const zlib = require('zlib'); | ||
const events = require('@whatwg-node/events'); | ||
@@ -1327,2 +1328,17 @@ const busboy = _interopDefault(require('busboy')); | ||
nodeRequest.once('response', nodeResponse => { | ||
let responseBody = nodeResponse; | ||
const contentEncoding = nodeResponse.headers['content-encoding']; | ||
switch (contentEncoding) { | ||
case 'x-gzip': | ||
case 'gzip': | ||
responseBody = nodeResponse.pipe(zlib.createGunzip()); | ||
break; | ||
case 'x-deflate': | ||
case 'deflate': | ||
responseBody = nodeResponse.pipe(zlib.createInflate()); | ||
break; | ||
case 'br': | ||
responseBody = nodeResponse.pipe(zlib.createBrotliDecompress()); | ||
break; | ||
} | ||
if (nodeResponse.headers.location) { | ||
@@ -1347,3 +1363,3 @@ if (fetchRequest.redirect === 'error') { | ||
const responseHeaders = nodeResponse.headers; | ||
const ponyfillResponse = new PonyfillResponse(nodeResponse, { | ||
const ponyfillResponse = new PonyfillResponse(responseBody, { | ||
status: nodeResponse.statusCode, | ||
@@ -1350,0 +1366,0 @@ statusText: nodeResponse.statusMessage, |
{ | ||
"name": "@whatwg-node/node-fetch", | ||
"version": "0.3.1", | ||
"version": "0.3.2-rc-20230314154619-367ff2a", | ||
"description": "Fetch API implementation for Node", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
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
111734
3059