undici icon indicating copy to clipboard operation
undici copied to clipboard

Handle the infamous raw deflate response from old servers

Open jimmywarting opened this issue 1 year ago • 2 comments

Bug Description

Something node-fetch and browser could handle was the infamous raw deflate response from old servers basically if the coding is either: coding === 'deflate' || coding === 'x-deflate' then read the first byte. if it match chunk[0] & 0x0F) === 0x08 then use zlib.createInflate() otherwise use zlib.createInflateRaw()

Reproducible By

You already have a test for it here: https://github.com/nodejs/undici/blob/51fa0fe3c62a770e8b1bbead0665f0bf9c5b81a2/test/node-fetch/main.js#L663-L672

Expected Behavior

Additional context

Relevant part that needs fixing: https://github.com/nodejs/undici/blob/51fa0fe3c62a770e8b1bbead0665f0bf9c5b81a2/lib/fetch/index.js#L2018-L2019

how node-fetch solved it: https://github.com/node-fetch/node-fetch/blob/7b86e946b02dfdd28f4f8fca3d73a022cbb5ca1e/src/index.js#L314-L350

jimmywarting avatar May 16 '23 15:05 jimmywarting

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

mcollina avatar May 16 '23 15:05 mcollina

don't exactly know how to translate it into your codebase. using pass through / transform stream or anything.

Remember to add unit tests.

just need to enable a existing test in the codebase that's currently skipped

jimmywarting avatar May 16 '23 18:05 jimmywarting