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
fix: fetch support compressed responses #2591
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about deflate and co?
@Uzlopak I can add support for deflate and br(?), but in this ugly(?) if/else style, it would be complex to support all combinations (it's possible to have more than one compression) const decoder = []
const codings = message.headers['content-encoding'].split(',')
for (const coding in codings) {
if (coding === 'gzip') decoder.push(zlib.createGunzip())
if (coding === 'deflate') decoder.push(..)
}
new ReadableStream({
start(controller) {
message.on('data', chunk => pipeline(Readable.from(chunk), ...decoders. () => {})
}
}) But I got an error. I'm not an expert in streams, and I'm clearly missing something. |
Maybe here you can get some clues how we do it in undici. |
@Uzlopak Thanks! I succeed to make it work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BEAUTIFUL
🎉 This PR is included in version 14.0.0-beta.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
teamwork makes the dream work |
fixes #2397 (comment)
This is a pretty naive solution that doesn't support more decoders easily (or multiple decoders at all), but I'm not expecting it in streams and such.
Improvements are welcome.