No content-length header when Content-type: gzip

I am using Worker with FixedLengthStream as a proxy.
If the request to Worker contains the Accept-Encoding: gzip header, then the content-length is omitted in the response.

I’ve noticed similar issue here: No content-length header when response is compressed
I’ve tried do set: Cache-Control: no-transform header in the request to proxy, but content-length isn’t returned.

How can I force Cloudflare to return the content-length which shall match exactly value set to: FixedLengthStream?

Request without Accept-Encoding (works fine):

curl -v ""

< content-type: application/json;charset=utf-8
< content-length: 19448

Request with Accept-Encoding: gzip (missing the content-length):

curl -v "" -H 'Accept-Encoding: gzip'

< content-type: application/json;charset=utf-8

My worker:

export default {
    async fetch(req, env) {
        const requestUrl = new URL(req.url);
        const apiurl = requestUrl.searchParams.get('apiurl');
        let url = new URL(apiurl);
        let hostname = url.hostname;

        let headers = {
            host: hostname,
            origin: hostname

        const response = await fetch(url, {
             headers: headers,
             method: req.method

        let responseSize = response.headers.get("content-length");
        const { writable, readable } = new FixedLengthStream(responseSize);
        return new Response(readable, response);

Cloudflare performs transparent (de)compression based on your Accept-Encoding header - if a response has to be (de)compressed on-the-fly then the Content-Length cannot be known up-front and will be omitted.


Thanks for your response.
Given that my service worker is just a proxy acting as a middleman between sender and destination, and I have no control of the sender request and destination response is there any way to configure this behavior?
I rely on Content-Length header, as the response is streamed. I am fine with disabling compression altogether if that makes the Content-Length predictable.