mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-23 20:31:25 +00:00
Support to decompress the brotli content-encoding
This commit is contained in:
parent
ee0f285e78
commit
6317098367
@ -12,6 +12,7 @@ const http = require('http'),
|
|||||||
logUtil = require('./log'),
|
logUtil = require('./log'),
|
||||||
co = require('co'),
|
co = require('co'),
|
||||||
HttpsServerMgr = require('./httpsServerMgr'),
|
HttpsServerMgr = require('./httpsServerMgr'),
|
||||||
|
brotliTorb = require('iltorb'),
|
||||||
Readable = require('stream').Readable;
|
Readable = require('stream').Readable;
|
||||||
|
|
||||||
const requestErrorHandler = require('./requestErrorHandler');
|
const requestErrorHandler = require('./requestErrorHandler');
|
||||||
@ -99,6 +100,7 @@ function fetchRemoteResponse(protocol, options, reqData, config) {
|
|||||||
const contentEncoding = resHeader['content-encoding'] || resHeader['Content-Encoding'];
|
const contentEncoding = resHeader['content-encoding'] || resHeader['Content-Encoding'];
|
||||||
const ifServerGzipped = /gzip/i.test(contentEncoding);
|
const ifServerGzipped = /gzip/i.test(contentEncoding);
|
||||||
const isServerDeflated = /deflate/i.test(contentEncoding);
|
const isServerDeflated = /deflate/i.test(contentEncoding);
|
||||||
|
const isBrotlied = /br/i.test(contentEncoding);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* when the content is unzipped, update the header content
|
* when the content is unzipped, update the header content
|
||||||
@ -133,6 +135,16 @@ function fetchRemoteResponse(protocol, options, reqData, config) {
|
|||||||
fulfill(buff);
|
fulfill(buff);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (isBrotlied && originContentLen) {
|
||||||
|
refactContentEncoding();
|
||||||
|
|
||||||
|
brotliTorb.decompress(serverResData, (err, buff) => {
|
||||||
|
if (err) {
|
||||||
|
rejectParsing(err);
|
||||||
|
} else {
|
||||||
|
fulfill(buff);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
fulfill(serverResData);
|
fulfill(serverResData);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
"es6-promise": "^3.3.1",
|
"es6-promise": "^3.3.1",
|
||||||
"express": "^4.8.5",
|
"express": "^4.8.5",
|
||||||
"iconv-lite": "^0.4.6",
|
"iconv-lite": "^0.4.6",
|
||||||
|
"iltorb": "^2.0.3",
|
||||||
"inquirer": "^3.0.1",
|
"inquirer": "^3.0.1",
|
||||||
"ip": "^0.3.2",
|
"ip": "^0.3.2",
|
||||||
"juicer": "^0.6.6-stable",
|
"juicer": "^0.6.6-stable",
|
||||||
@ -92,7 +93,7 @@
|
|||||||
"worker-loader": "^0.7.1"
|
"worker-loader": "^0.7.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish":"npm run buildweb",
|
"prepublish": "npm run buildweb",
|
||||||
"test": "node test.js",
|
"test": "node test.js",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"testserver": "node test/server/startServer.js",
|
"testserver": "node test/server/startServer.js",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user