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
"I want to make an image request" #279
Comments
That's an interesting idea, but should not affect fetch()'s CSP check. I'm not sure if that argues for having a distinct request's CSP context (and request's context can default to that unless otherwise specified). |
I guess the context would always be |
If we use something like "context" for sensible defaults, it should also determine if the request should use CORS by default. |
This is cool. Just to help my understanding: this is not just sugar for setting headers manually in the request initialization code? For, X-origin requests, currently changing the Accept header will make it a CORS request, right? But, you are saying "if you set the Accept header via this special context field, then we won't require a CORS preflight". Do we try to enforce current policies once you use the context method? As an example, if I set context to "font", do you allow cross-origin requests? Currently, Firefox (and the spec) does not allow cross-origin font loads. |
CORS-or-not will be an option, but yeah, setting the "context" will give this value the correct default for the type. (as long as there aren't security issues, of course) |
I think this needs to be explained more first, what exactly this would do. Currently we have not really explained at a Fetch level what headers UAs might add for various fetches. |
I'm discussing this idea with @igrigorik in w3c/preload#17 (comment) at the moment. It's still not entirely clear to me what the division of labor needs to be, but hopefully once we have the answers to the questions in that thread, we can open some issues against https://github.com/whatwg/fetch to add new features. |
Closing this in favor of whatwg/fetch#43. |
Browsers make requests differently depending on their context.
http://jsbin.com/yacar/1/quiet - here I'm request the same url, one using XHR and one using
<img>
. The browser cannot dedupe these as they have separateAccept
headers.When using
fetch()
and populating caches, it'd be useful to ask the browser to make the request as if it were for an "image" or a "font". These are terms we currently use forfetchEvent.context
.I propose we move
.context
ontoRequest
objects, and allow it to be set in constructor. The initial value of "context" will affect headers in a way that's UA-specific (eg, Chrome Accepts image/webp, Firefox does not). Any user-set headers will take priority.The text was updated successfully, but these errors were encountered: