nodejs / nodejs/undici

Expose "Content-Encoding" handling publicly

Open
#3,412 13 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
7.7k
Forks
880
Avg merge
2d 16h
Merged PRs (30d)
68

Description

This would solve...

Hi! In Interceptors, we are looking at improving the compatibility of response handling for mocked responses. As a part of that effort, we'd like to produce an identical behavior that Undici exhibits with compressed response bodies.

The implementation should look like...

If the following handling logic is a tad abstracted and exposed as a standalone function, it could help us a lot to stay consistent and make countless developers' tests more reliable:

https://github.com/nodejs/undici/blob/c1f7d2a9a6556e5a34fdf5ed38c77ce636f1ff02/lib/web/fetch/index.js#L2139-L2161

This is a brief look at the implementation. It may require more effort than just abstracting this code block. We can discuss the exact API in detail together. I imagine it being something like decode(response: Response): Decoder[]. Perhaps exposing the pipeline would make for an even easier consumption.

I have also considered...

We are considering writing the Content-Encoding handling by hand but I'd like to join efforts on this one. I don't wish to repeat things. I like using the platform. I like Undici.

Additional context

I'm interested in opening a pull request and seeing this through, given it's something you agree on. Let me know.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Content-Encoding handling in lib/web/fetch/index.js at the linked lines, then review the surrounding pipeline logic and the Interceptors compatibility need. Define the public function or pipeline API with maintainers, and verify that exposed handling matches Undici's compressed response behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.