cloudflare / cloudflare/workerd

Responses with multiple `Content-Encoding` headers not decompressed

Open
#7,051 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

Responses containing multiple content-encoding headers do not fully decompress the body, resulting in an unexpected value being received.

It appears that workerd looks for an exact value match in the `content-encoding` header when deciding what to do (https://github.com/cloudflare/workerd/blob/main/src/workerd/api/system-streams.c%2B%2B#L413-L428), and as a result does not seem to support stacked headers, as they're merged into a comma-delimited list that is not walked through from what i understand.

Example reproduction in a branch in our repo - https://github.com/cloudflare/vinext/blob/codex%2Fworkerd-stacked-content-encoding-repro/repros/workerd-stacked-content-encoding/README.md

Image

Whereas, Node will decode for both of the values and return the expected response.

This surfaced in a customer's reproduction in https://github.com/cloudflare/vinext/issues/2983

Contributor guide

Open the contributing guide

Research direction

Start at src/workerd/api/system-streams.c++ around lines 413-428, where content-encoding is checked, and read the reproduction in the linked vinext README. Trace how comma-delimited encoding values are handled and verify the response body is fully decompressed for stacked encodings, matching Node's result.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.