mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-24 04:41:26 +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'),
|
||||
co = require('co'),
|
||||
HttpsServerMgr = require('./httpsServerMgr'),
|
||||
brotliTorb = require('iltorb'),
|
||||
Readable = require('stream').Readable;
|
||||
|
||||
const requestErrorHandler = require('./requestErrorHandler');
|
||||
@ -99,6 +100,7 @@ function fetchRemoteResponse(protocol, options, reqData, config) {
|
||||
const contentEncoding = resHeader['content-encoding'] || resHeader['Content-Encoding'];
|
||||
const ifServerGzipped = /gzip/i.test(contentEncoding);
|
||||
const isServerDeflated = /deflate/i.test(contentEncoding);
|
||||
const isBrotlied = /br/i.test(contentEncoding);
|
||||
|
||||
/**
|
||||
* when the content is unzipped, update the header content
|
||||
@ -133,6 +135,16 @@ function fetchRemoteResponse(protocol, options, reqData, config) {
|
||||
fulfill(buff);
|
||||
}
|
||||
});
|
||||
} else if (isBrotlied && originContentLen) {
|
||||
refactContentEncoding();
|
||||
|
||||
brotliTorb.decompress(serverResData, (err, buff) => {
|
||||
if (err) {
|
||||
rejectParsing(err);
|
||||
} else {
|
||||
fulfill(buff);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fulfill(serverResData);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
"es6-promise": "^3.3.1",
|
||||
"express": "^4.8.5",
|
||||
"iconv-lite": "^0.4.6",
|
||||
"iltorb": "^2.0.3",
|
||||
"inquirer": "^3.0.1",
|
||||
"ip": "^0.3.2",
|
||||
"juicer": "^0.6.6-stable",
|
||||
|
Loading…
x
Reference in New Issue
Block a user