Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
zlib.gunzip(body, (err, buffer) => {
if (err) {
reject(new Error(err.message || err));
} else {
resolve(buffer);
}
});
});
}
res.on('end', function() {
var buffer = Buffer.concat(chunks);
var compression = res.headers['content-encoding'];
var callback = _createRequestCallback(address, encoding, done);
var location = res.headers.location;
if (location) return _request(location, encoding, done, n + 1 || 1);
if (compression === 'gzip') {
return zlib.gunzip(buffer, callback);
} else if (compression === 'deflate') {
return zlib.inflateRaw(buffer, callback);
} else {
callback(undefined, buffer);
}
});
}).on('error', function(err) {