-
Notifications
You must be signed in to change notification settings - Fork 315
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
spec should be more explicit about accessing internal body on opaque Responses #710
Comments
It's a bit more complicated. Since if |
I guess the part about handling the respondWith() body really needs to go in the html spec when it integrates with fetch. And I guess SW spec implicitly handles this for Cache by just kind of keeping them in a conceptual list. Maybe this can be closed? |
I think you're correct that some aspects of |
Replaced "used flag" text with "disturbed" and made the input response's body stream of |
I believe more filtered response bits for foreign fetch are being followed up in #841 and we'll continue to discuss there. Closing. |
Wait wait wait. You allow modification of opaque responses? I don't think that's a good idea. HEAD to an opaque response should be a network error. |
Sorry to have not been specific with the description above. Setting the body to null is for the case where We're not mutating the state of the stored response, but just returning a copy of the response after removing the body as it's a HEAD request. |
Yes and I'm saying that should not be possible for opaque responses. You don't "just" change opaque responses. |
Pretty sure this behavior has been in the spec for a long time, @annevk. We definitely honor it in gecko: https://dxr.mozilla.org/mozilla-central/source/dom/cache/Manager.cpp#501 The rational is if you do a HEAD request to a cross-origin server without CORS, you still get a response without a body. The Cache API should behave the same. |
Yes, but you cannot do a "no-cors" HEAD. Allowing that, even just for the cache, seems like a same-origin policy violation. |
I think this is probably more an issue with Cache API spec not reflecting that Responses are serialized and deserialized. Its really creating a new Response on each .match(). If its a HEAD, its creating a new Response without a body. That seems reasonable and safe for opaque responses to me. (And its what we currently do in the impl.) |
@wanderview see tc39/proposal-cancelable-promises#4 (comment) for some of the concerns with altering opaque responses. They don't necessarily apply here, but I'm still deeply skeptical of allowing such things. E.g., for one, you shouldn't be able to tell if an opaque response has a body or not. |
@annevk, so you think these should have different behavior? Where a fetch event is generated from an
Vs:
You are saying that code snippet 1 should NOT show the image in the Per the current spec language both of these snippets result in the same behavior. The image is not shown because the Response was created via a HEAD Request. |
I'm worried about changing opaque responses. I'd appreciate input from security folks since this changes the same-origin policy. I would probably throw for the latter case as I suggested earlier. |
We would need @jakearchibald's input to change this as well, I think. |
In any case, this should probably be a separate issue. @jungkees did not add this behavior to the spec in this commit. It has been there for a long time. |
Also, I really don't understand the security concerns. We're already hiding opaque response bodies from script. All removing the body on HEAD does it further hide the body from the browser. Removing information seems generally safe. |
I just pointed to a thread that explained how it'd be unsafe if you remove half of the body. |
To me, @wanderview's snippet 1 and snippet 2 having the same behavior makes sense. Setting the response's body to null for a HEAD request in
I'm not sure I understand this from the context of our discussion here. Can you share a pointer? |
See #710 (comment) for the pointer. |
This is not removing half the body. Its removing the full body just like the network stack has always done for HEAD requests. |
Yes, but you stated "Removing information seems generally safe." which I had just shown to be untrue. And there's a significant difference between the server not including the body based on a |
F2F: we should do whatever fetch does here. If fetch disallows no-cors HEAD requests, cache.match shouldn't generate them from opaque responses. At a quick glance, it appears that fetch does allow it, though. @wanderview is writing an issue. |
I don't understand why the F2F considered network behavior identical to the user agent modifying an opaque response. |
Its not arbitrary modification. Its treating the response has having no body. That is exactly what the browser already does if it gets a HEAD response with a body. |
Here is where gecko ignores the body regardless of what the server sends: https://dxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/nsHttpTransaction.cpp#285 |
Sure, but there might be different HTTP headers in play. |
Not sure what other browsers do, but in gecko our http cache will only match a HEAD request if the entry in the cache is also a HEAD. Is that what other browsers do? |
I do not believe that HTTP caching is supported at all for a HEAD request in Edge. |
F2F:
|
Looks like blink fixed this in August. We are working on our fix now. |
This fix will ship in FF53. |
From reading the non-normative text it appears that respondWith() and Cache.put() should process the internal body of an opaque response. This is confusing from the normative steps, however, since they only refer to the "body" which fetch defines as null for opaque responses.
It would be nice to explicitly reference the internal body in these cases in the normative text.
The text was updated successfully, but these errors were encountered: