-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow custom services to respond with
Content-Encoding
header
Previously, if the response from a custom service included a `Content-Encoding` header, we would respond with decoded content to `workerd` without removing the `Content-Encoding` header. This caused `workerd` to try to decode already decoded content, resulting in an error. This was particularly a problem with `wrangler pages dev`, as upstream dev servers could very easily return gzipped content. This change updates the `writeResponse()` function with code from Miniflare 2, to re-encode the body before responding. Note, due to a fixed but unreleased bug in `undici` (nodejs/undici#2159), defining a custom service that directly proxies somewhere else with `fetch()` like `wrangler pages dev` will fail, if `Content-Encoding` contains multiple encodings. Closes cloudflare/workers-sdk#3408
- Loading branch information
Showing
2 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters