Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle the infamous raw deflate response from old servers #2128

Closed
jimmywarting opened this issue May 16, 2023 · 2 comments · Fixed by #2650
Closed

Handle the infamous raw deflate response from old servers #2128

jimmywarting opened this issue May 16, 2023 · 2 comments · Fixed by #2650
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jimmywarting
Copy link
Contributor

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:

xit('should decompress deflate raw response from old apache server', () => {
const url = `${base}deflate-raw`
return fetch(url).then(res => {
expect(res.headers.get('content-type')).to.equal('text/plain')
return res.text().then(result => {
expect(result).to.be.a('string')
expect(result).to.equal('hello world')
})
})
})

Expected Behavior

Additional context

Relevant part that needs fixing:

undici/lib/fetch/index.js

Lines 2018 to 2019 in 51fa0fe

} else if (coding === 'deflate') {
decoders.push(zlib.createInflate())

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

@jimmywarting jimmywarting added the bug Something isn't working label May 16, 2023
@mcollina mcollina added enhancement New feature or request good first issue Good for newcomers and removed bug Something isn't working labels May 16, 2023
@mcollina
Copy link
Member

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

@jimmywarting
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants