Update util.js
Added support uncompressed XML files
This commit is contained in:
@ -139,9 +139,16 @@ function getGzipped(url) {
|
|||||||
url: url,
|
url: url,
|
||||||
responseType:'stream'
|
responseType:'stream'
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
var gunzip = zlib.createGunzip()
|
let stream
|
||||||
|
if(res.headers['content-type'] === 'application/xml') {
|
||||||
|
stream = res.data
|
||||||
|
} else {
|
||||||
|
let gunzip = zlib.createGunzip()
|
||||||
res.data.pipe(gunzip)
|
res.data.pipe(gunzip)
|
||||||
gunzip.on('data', function(data) {
|
stream = gunzip
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.on('data', function(data) {
|
||||||
buffer.push(data.toString())
|
buffer.push(data.toString())
|
||||||
}).on("end", function() {
|
}).on("end", function() {
|
||||||
resolve(buffer.join(""))
|
resolve(buffer.join(""))
|
||||||
|
Reference in New Issue
Block a user