cloudflare / cloudflare/workerd

🐛 BUG: Brotli response not decoded

Open
#1,587 3 comments 0 reactions 0 assignees View on GitHub
feature request
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

### Which Cloudflare product(s) does this pertain to?

Miniflare

### What version(s) of the tool(s) are you using?

^3.20231218.4

### What version of Node are you using?

18.19.0

### What operating system are you using?

Mac

### Describe the Bug

The result of `res.text()` of a response with `content-encoding: br` is not decoded, but when it is `gzip`, it is correctly decoded.

This worker returns a mess:

```ts
export default {
async fetch() {
const res = await fetch("https://blog.cloudflare.com/this-is-brotli-from-origin", {
headers: {
"accept-encoding": "br, gzip, deflate"
}
});
return new Response(await res.text(), {
headers: {
"content-type": "text/html"
}
});
}
}
```
This worker returns the correct HTML:

```ts
export default {
async fetch() {
const res = await fetch("https://blog.cloudflare.com/this-is-brotli-from-origin", {
headers: {
"accept-encoding": "gzip, deflate"
}
});
return new Response(await res.text(), {
headers: {
"content-type": "text/html"
}
});
}
}
```

### Please provide a link to a minimal reproduction

_No response_

### Please provide any relevant error logs

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.