diff --git a/lib/download.js b/lib/download.js index 34f93a8..b0b68f0 100644 --- a/lib/download.js +++ b/lib/download.js @@ -1,13 +1,15 @@ const https = require('https'), fs = require('fs'), HttpsProxyAgent = require('https-proxy-agent'), - url = require('url'); + url = require('url'), + zlib = require('zlib'); const binaryPath = process.argv[2], httpPath = process.argv[3], proxyHost = process.argv[4], proxyPort = process.argv[5], useCaCertificate = process.argv[6]; var fileStream = fs.createWriteStream(binaryPath); var options = url.parse(httpPath); +options.headers = { 'Accept-Encoding': 'gzip' }; if(proxyHost && proxyPort) { options.agent = new HttpsProxyAgent({ host: proxyHost, @@ -17,13 +19,13 @@ if(proxyHost && proxyPort) { try { options.ca = fs.readFileSync(useCaCertificate); } catch(err) { - console.log("failed to read cert file", err) + console.log('failed to read cert file', err); } } } https.get(options, function (response) { - response.pipe(fileStream); + response.pipe(zlib.createGunzip()).pipe(fileStream); // unzip response.on('error', function(err) { console.error('Got Error in binary download response', err); });