From c96a6b33a34725b018409b310899f130ac26d3f3 Mon Sep 17 00:00:00 2001 From: Jesse Yang Date: Wed, 21 Oct 2020 17:03:08 -0700 Subject: [PATCH] build: let webpack proxy server handle more content encoding --- superset-frontend/webpack.proxy-config.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/superset-frontend/webpack.proxy-config.js b/superset-frontend/webpack.proxy-config.js index 931356db745d7..050a57bfc3ffe 100644 --- a/superset-frontend/webpack.proxy-config.js +++ b/superset-frontend/webpack.proxy-config.js @@ -109,12 +109,20 @@ function copyHeaders(originalResponse, response) { function processHTML(proxyResponse, response) { let body = Buffer.from([]); let originalResponse = proxyResponse; + let uncompress; + const responseEncoding = originalResponse.headers['content-encoding']; // decode GZIP response - if (originalResponse.headers['content-encoding'] === 'gzip') { - const gunzip = zlib.createGunzip(); - originalResponse.pipe(gunzip); - originalResponse = gunzip; + if (responseEncoding === 'gzip') { + uncompress = zlib.createGunzip(); + } else if (responseEncoding === 'br') { + uncompress = zlib.createBrotliDecompress(); + } else if (responseEncoding === 'deflate') { + uncompress = zlib.createInflate(); + } + if (uncompress) { + originalResponse.pipe(uncompress); + originalResponse = uncompress; } originalResponse