From 4e471aec2ef8d9eecb6c88fcd2554e26621d223b Mon Sep 17 00:00:00 2001 From: freearhey Date: Thu, 15 Aug 2019 00:42:09 +0300 Subject: [PATCH] Update util.js Added support uncompressed XML files --- helpers/util.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/helpers/util.js b/helpers/util.js index 1e1d20f70..6c5dbac85 100644 --- a/helpers/util.js +++ b/helpers/util.js @@ -139,9 +139,16 @@ function getGzipped(url) { url: url, responseType:'stream' }).then(res => { - var gunzip = zlib.createGunzip() - res.data.pipe(gunzip) - gunzip.on('data', function(data) { + let stream + if(res.headers['content-type'] === 'application/xml') { + stream = res.data + } else { + let gunzip = zlib.createGunzip() + res.data.pipe(gunzip) + stream = gunzip + } + + stream.on('data', function(data) { buffer.push(data.toString()) }).on("end", function() { resolve(buffer.join(""))