Original mentioned here as feedback for the dev mode.
request.headers.get('Accept-Encoding');
Currently the wrangler dev runtime has different behavior for the Accept-Encoding header than a cloud deployed worker. Accessing it returns the actual values of a client (e.g. gzip, deflate, br) which can be misleading as later on those won't be forwarded but always replaced with gzip. Having them aligned helps to be consistent so developers can be aware of that circumstance before running the worker in production.
ok - from my investigation when sending Accept-Encoding: gzip, deflate, br as a request header
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
let accept_encoding = request.headers.get("Accept-Encoding")
console.log(accept_encoding)
let response = await fetch("https://example.com")
let content_encoding = response.headers.get("Content-Encoding")
console.log(content_encoding)
return response
}
|command|console.log(accept_encoding)|console.log(content_encoding)|observed Content-Encoding response header|
|---|---|---|---|
|wrangler dev|gzip, deflate, br|null|Header does not exist|
|wrangler preview|gzip, deflate, br|null|Header does not exist|
|wrangler publish|gzip|null|br|
This will be fixed when we release the stuff in #1085 - i just built wrangler dev from branch avery/edge-dev-server and i get the following:
|command|console.log(accept_encoding)|console.log(content_encoding)|observed Content-Encoding response header|
|---|---|---|---|
|wrangler dev|gzip|null|br|
this is the same you see when you publish a worker 馃槃
edit: for context, wrangler dev is not actually offline, it connects to a preview service running the workers runtime in GCP. our next upgrade to wrangler dev makes those requests go through Cloudflare's edge network instead of GCP, which will give a much more accurate depiction of what's going to happen when you push to production.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
The issue is resolved with the recent change of using the latest edge workers.
Most helpful comment
ok - from my investigation when sending
Accept-Encoding: gzip, deflate, bras a request header|command|
console.log(accept_encoding)|console.log(content_encoding)|observedContent-Encodingresponse header||---|---|---|---|
|
wrangler dev|gzip, deflate, br|null|Header does not exist||
wrangler preview|gzip, deflate, br|null|Header does not exist||
wrangler publish|gzip|null|br|