Skip to content

How does networkFetch handle redirects? #47

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

Closed
jakearchibald opened this issue May 11, 2013 · 12 comments
Closed

How does networkFetch handle redirects? #47

jakearchibald opened this issue May 11, 2013 · 12 comments

Comments

@jakearchibald
Copy link
Contributor

If a redirect is issued, I want to know about it in case it's a captive portal.

@annevk
Copy link
Member

annevk commented May 11, 2013

I think we should offer an API that does not follow redirects automatically.

I also think that networkFetch (which should just be fetch) should not be introduced by this specification, but I guess it's fine for now so we have something to reason about.

@jakearchibald
Copy link
Contributor Author

Without it we're unable to do AppCache's FALLBACK feature. As in, try the network & do something else on failure.

@annevk
Copy link
Member

annevk commented May 13, 2013

All I'm saying is that you don't want to put all these different features that make a lot of sense outside this specific worker context as well, in the same specification. Because at that point you're doing the much feared scenario solving rather than building a layered architecture.

@jakearchibald
Copy link
Contributor Author

Ahh yes, makes sense

@slightlyoff
Copy link
Contributor

...but we can't solve this via XHR, so we need something that returns Response objects and takes Request objects as parameters. The idea of simply punting without explaining what to do doesn't work. It's de-facto layered in the sense that networkFetch() is clearly doing what the lower layer does. I'm happy to bikeshed it to oblivion, though.

As for who introduces fetch(), is that really something to argue about? I don't care, and I'm pretty sure you don't either...assuming the API is sane and does what you like. In any case, calling it networkFetch() or httpFetch() (my preferred name now) at least gives us a plausible way to avoid the naming conflict when we introduce fetch() everywhere. If we like what we get out of the design exercise so much that it becomes the fetch() API signature, so much the better! We just deprecate httpFetch() (or remove it, depending on when we make the cut over).

@slightlyoff
Copy link
Contributor

per today's f2f, regarding the basic policy, we decided:

  • documents don't see redirects for fetches they generate
  • service workers get sent both initial fetches and fetches generated by server redirects (but documents don't see them)
  • the previous point means that e.forwardTo() will generate a new onfetch in the SW, because the response will be sent to the document which will issue a new request to the SW
  • fetches sent by the SW (e.g., via fetch()) which generate redirects do not re-enter the SW. Conceptually, if there was an SW "below" the one in question, it would then get 2 bites at the apple

There's a relativity principle of redirects: each context can't see the redirects, but the layer "behind" it can.

@slightlyoff
Copy link
Contributor

We've had quite a lot more discussion in the last hour and have come to a different conclusion:

  • a redirect from the SW (either e.forwardTo() or a 3xx Response) DOES issue a new onfetch to the SW
  • any time you go to the network layer, redirects are transparently followed. That implies that fetch() calls and server-sent redirects do not re-enter the SW as new onfetch events.

The motivator here is an xss-amplification due to HTTP-only cookie handling and capability URL leakage. The new resolution preserves the security properties of current browser behavior.

@annevk
Copy link
Member

annevk commented Jan 23, 2014

@KenjiBaheux
Copy link
Collaborator

Assuming this is either superseded by or a duplicate of #412

@annevk
Copy link
Member

annevk commented Sep 5, 2014

No it's not a duplicate. 304 is not a redirect...

@annevk
Copy link
Member

annevk commented Sep 5, 2014

Handling redirects is completely spelled out in the specification I think. They are followed.

@KenjiBaheux
Copy link
Collaborator

Tracked at crbug.com/402389 for Blink.

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

No branches or pull requests

4 participants