Gzip

Any bright ideas for the best approach for handling gzipped data that's served as binary blobs with no headers? Would a proxy worker which adds a gzip header (e.g. a service-worker) work and give me uncompressed text?
2 Replies
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
WillTolmie
WillTolmieOP•3y ago
Ah nice I'll look cheers
const response = await fetch(url)

const textDecoder = new TextDecoder()
if (response.body) {
let readable = response.body
.pipeThrough(new DecompressionStream("gzip"))
.pipeThrough(new TextDecoderStream())
for await (let chunk of readable) {
var string = textDecoder.decode(chunk)
console.log(string)
}
}
const response = await fetch(url)

const textDecoder = new TextDecoder()
if (response.body) {
let readable = response.body
.pipeThrough(new DecompressionStream("gzip"))
.pipeThrough(new TextDecoderStream())
for await (let chunk of readable) {
var string = textDecoder.decode(chunk)
console.log(string)
}
}
That works nicely 🙂 thanks @hannes_1234
Want results from more Discord servers?
Add your server