Content-Encoding not set

Hoping someone can help me with a weird problem: I am sending a gzipped object from R2 through a Worker in a Response. I set Content-Encoding: gzip in the response's headers. When I send the request from HTTPie (desktop REST client), I see the appropriate Content-Encoding header in the response. But when the request comes from the browser (Chrome), no Content-Encoding header is set in the response at all, and Chrome does not decompress the response body as it should. Why would the Content-Encoding header not be set or ignored in Chrome? Is this a CORS issue?
1 Reply
Jason Hostetter
Jason HostetterOP10mo ago
It actually seems like maybe the real problem is that the response body is getting gzipped again by the worker automatically, so that when Chrome decompresses it, the body is still a gzipped resource. Regarding the Content-Encoding header, for some reason when I change the Accept-Encoding header in the request to just gzip instead of the default gzip, deflate, br, then the correct Content-Encoding header shows up in the response. Not sure what that's about It turns out I had to set the encodeBody: 'manual' option on the Response constructor from R2 to prevent double compression.
Want results from more Discord servers?
Add your server