[slightlyoff/ServiceWorker] Send correct Accept header with fetch() request (#945)

We currently use the `Accept` header to determine if a browser supports WebP, and to change our response on the server. However, fetch() requests always send `'*/*'` by default, so our implementation would fail.

Of course, we could manually override the `Accept` header as `fetch(url, {headers: {Accept: 'img/webp'}})`, however client side WebP detection is quite clunky (and we might also need some other parts of the `Accept` header).

Similarly, we could save the original `Accept` header to a cookie or session variable and use it as fallback, but this behaviour seems quite fragile and hacky.

Is there/will there be a way to send all default browser request headers with `fetch()`?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/945

Received on Friday, 5 August 2016 17:29:28 UTC