mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
fix: fixed Brotli decompression; (#5353)
test: added decompression tests; fix: added legacy `x-gzip` & `x-compress` encoding types;
This commit is contained in:
@@ -23,6 +23,11 @@ import EventEmitter from 'events';
|
||||
const zlibOptions = {
|
||||
flush: zlib.constants.Z_SYNC_FLUSH,
|
||||
finishFlush: zlib.constants.Z_SYNC_FLUSH
|
||||
};
|
||||
|
||||
const brotliOptions = {
|
||||
flush: zlib.constants.BROTLI_OPERATION_FLUSH,
|
||||
finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH
|
||||
}
|
||||
|
||||
const isBrotliSupported = utils.isFunction(zlib.createBrotliDecompress);
|
||||
@@ -417,7 +422,9 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
||||
switch (res.headers['content-encoding']) {
|
||||
/*eslint default-case:0*/
|
||||
case 'gzip':
|
||||
case 'x-gzip':
|
||||
case 'compress':
|
||||
case 'x-compress':
|
||||
case 'deflate':
|
||||
// add the unzipper to the body stream processing pipeline
|
||||
streams.push(zlib.createUnzip(zlibOptions));
|
||||
@@ -427,7 +434,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
||||
break;
|
||||
case 'br':
|
||||
if (isBrotliSupported) {
|
||||
streams.push(zlib.createBrotliDecompress(zlibOptions));
|
||||
streams.push(zlib.createBrotliDecompress(brotliOptions));
|
||||
delete res.headers['content-encoding'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ const isStandardBrowserEnv = (() => {
|
||||
const isStandardBrowserWebWorkerEnv = (() => {
|
||||
return (
|
||||
typeof WorkerGlobalScope !== 'undefined' &&
|
||||
// eslint-disable-next-line no-undef
|
||||
self instanceof WorkerGlobalScope &&
|
||||
typeof self.importScripts === 'function'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user