mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-12 11:30:01 -04:00
22 lines
No EOL
614 B
JavaScript
22 lines
No EOL
614 B
JavaScript
const zlib = require('zlib');
|
|
|
|
function decompress(ctx) {
|
|
if (!ctx.body || !ctx.remoteResponse) return;
|
|
try {
|
|
switch(ctx.headers['content-encoding']) {
|
|
case 'br':
|
|
ctx.body = zlib.brotliDecompressSync(ctx.body);
|
|
break;
|
|
case 'gzip':
|
|
ctx.body = zlib.gunzipSync(ctx.body);
|
|
break;
|
|
case 'deflate':
|
|
ctx.body = zlib.inflateRawSync(ctx.body);
|
|
break;
|
|
};
|
|
} catch(err) {};
|
|
delete ctx.headers['content-encoding'];
|
|
return true;
|
|
};
|
|
|
|
module.exports = decompress; |