Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

[dev] Different behavior of "Accept-Encoding" header #1425

Closed
autarc opened this issue Jun 30, 2020 · 4 comments
Closed

[dev] Different behavior of "Accept-Encoding" header #1425

autarc opened this issue Jun 30, 2020 · 4 comments

Comments

@autarc
Copy link

autarc commented Jun 30, 2020

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.

@EverlastingBugstopper
Copy link
Contributor

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

@EverlastingBugstopper
Copy link
Contributor

EverlastingBugstopper commented Jun 30, 2020

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.

@stale
Copy link

stale bot commented Aug 30, 2020

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.

@stale stale bot added the wontfix label Aug 30, 2020
@autarc
Copy link
Author

autarc commented Aug 31, 2020

The issue is resolved with the recent change of using the latest edge workers.

@autarc autarc closed this as completed Aug 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants