Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out if request header mutation is possible #391

Open
annevk opened this issue Sep 27, 2016 · 4 comments
Open

Figure out if request header mutation is possible #391

annevk opened this issue Sep 27, 2016 · 4 comments

Comments

@annevk
Copy link
Member

annevk commented Sep 27, 2016

There's a number of things that would be nice to mutate in a request as it passes through a service worker, but a particular one that comes up often and might be the easiest is adding a header.

Adding headers seems fine when request mode is "same-origin" or "cors", but harder when it is "navigate" or "no-cors" (see also #380).

For "navigate" and "no-cors" we could maybe tag an additional flag to the added headers (making the map a little more complicated, which I guess we could do after we fix some other issues with headers) and drop the added headers upon encountering a (cross-origin?) redirect.

@RReverser
Copy link
Member

What exactly would be the point of such flag on the request? Meaning, why not just allow to add headers or any potentially same-origin request (incl. no-cors and navigate), and just drop them when it goes to another origin?

@annevk
Copy link
Member Author

annevk commented Mar 1, 2017

Well, you can set certain headers today even for no-cors (e.g., Accept). So the flag would mostly be about preserving those, while removing the others. If we drop all headers, while simpler, we'd also end up regressing on functionality we offer today.

@RReverser
Copy link
Member

RReverser commented Mar 1, 2017

@annevk Yes, I meant removing only non-whitelisted headers (whitelist is already part of the spec) on cross-origin redirect. This will preserve backward compatibility and will still try to send as much changed headers as allowed for that specific context.

@annevk
Copy link
Member Author

annevk commented Mar 1, 2017

That could maybe work. A problem with that approach could be that we also have certain non-safelisted headers added by other standards at the API layer. I'm not entirely sure whether that is the case however. There are headers that other standards add that violate CORS, such as DNT, Upgrade-Insecure-Requests, etc., but maybe all use a hook at the network layer in which case it would be less of an issue.

@mikewest do you know?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants