Add brotli decompression to redownload.js
This commit is contained in:
@@ -704,10 +704,10 @@ var Redownload = function() {
|
||||
|
||||
debug('Downloading %s', entry.url);
|
||||
|
||||
// Always add gzip and webp headers before sending, in case the server listens to them
|
||||
// Always add compression and webp headers before sending, in case the server listens to them
|
||||
var reqHeaders = [];
|
||||
reqHeaders['Accept'] = '*/*,image/webp';
|
||||
reqHeaders['Accept-Encoding'] = 'gzip, deflate';
|
||||
reqHeaders['Accept-Encoding'] = 'gzip, deflate, br';
|
||||
reqHeaders['Connection'] = 'keep-alive';
|
||||
|
||||
var requestOptions = {
|
||||
@@ -836,6 +836,28 @@ var Redownload = function() {
|
||||
bodySize += data.length;
|
||||
}).pipe(deflate);
|
||||
|
||||
break;
|
||||
case 'br':
|
||||
|
||||
var brotli = zlib.createBrotliDecompress();
|
||||
|
||||
brotli.on('data', function (data) {
|
||||
|
||||
bodyChunks.push(data);
|
||||
uncompressedSize += data.length;
|
||||
}).on('end', function () {
|
||||
isCompressed = true;
|
||||
tally();
|
||||
}).on('error', function(err) {
|
||||
debug('Error while decoding %s', requestOptions.url);
|
||||
debug(err);
|
||||
callback(err);
|
||||
});
|
||||
|
||||
res.on('data', function (data) {
|
||||
bodySize += data.length;
|
||||
}).pipe(brotli);
|
||||
|
||||
break;
|
||||
default:
|
||||
res.on('data', function (data) {
|
||||
|
||||
Reference in New Issue
Block a user