2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-11 18:02:32 +03:00

fix(http): add zlib headers if missing (#5497)

This commit is contained in:
ItsNotGoodName
2023-01-30 14:49:37 -08:00
committed by GitHub
parent 9915635c69
commit 65e8d1e28c
3 changed files with 43 additions and 2 deletions
+6 -2
View File
@@ -35,6 +35,7 @@ const pipelineAsync = util.promisify(stream.pipeline);
const finishedAsync = util.promisify(stream.finished);
const gzip = util.promisify(zlib.gzip);
const deflate = util.promisify(zlib.deflate);
const deflateRaw = util.promisify(zlib.deflateRaw);
const brotliCompress = util.promisify(zlib.brotliCompress);
function toleranceRange(positive, negative) {
@@ -493,13 +494,16 @@ describe('supports http with nodejs', function () {
describe('algorithms', ()=> {
const responseBody ='str';
for (const [type, zipped] of Object.entries({
for (const [typeName, zipped] of Object.entries({
gzip: gzip(responseBody),
compress: gzip(responseBody),
deflate: deflate(responseBody),
'deflate-raw': deflateRaw(responseBody),
br: brotliCompress(responseBody)
})) {
describe(`${type} decompression`, async () => {
const type = typeName.split('-')[0];
describe(`${typeName} decompression`, async () => {
it(`should support decompression`, async () => {
server = await startHTTPServer(async (req, res) => {
res.setHeader('Content-Encoding', type);