Update util.js

Added support uncompressed XML files
This commit is contained in:
freearhey 2019-08-15 00:42:09 +03:00
parent 74f029748e
commit 4e471aec2e
1 changed files with 10 additions and 3 deletions

View File

@ -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(""))