- From: Tsuyoshi Horo <notifications@github.com>
- Date: Wed, 05 Aug 2015 22:19:23 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Message-ID: <whatwg/fetch/issues/101/128245354@github.com>
I didn't know that the redirect flag of navigation request is "manual". I think this will change the behavior of existing Service Workers. Example: - The server returns 302 redirect responses for these URLs: 1. https://www.example.com/scope/in_scope_redirect -> https://www.example.com/scope/dir/destination 2. https://www.example.com/scope/out_scope_redirect -> https://www.example.com/out_scope/destination - The server returns 200 responses with the body "\<img src='./image.png'\>" for these URLs: 1. https://www.example.com/scope/dir/destination 2. https://www.example.com/out_scope/destination - A serviceworker.js is registered for https://www.example.com/scope/ ```javascript self.addEventListener('fetch', function(event) { if (event.request.url == 'https://www.example.com/scope/in_scope_sw_redirect') { event.respondWith(fetch('https://www.example.com/scope/dir/destination')); } else if (event.request.url == 'https://www.example.com/scope/out_scope_sw_redirect') { event.respondWith(fetch('https://www.example.com/out_scope/destination')); } else { event.respondWith(fetch(event.request)); } }); ``` - The current behavior in Chrome: 1. When the user opens "https://www.example.com/scope/in_scope_redirect". The URL bar of the pege is "https://www.example.com/scope/in_scope_redirect". The page sends a fetch request "https://www.example.com/scope/image.png" via the Service Worker. 2. When the user opens "https://www.example.com/scope/out_scope_redirect". The URL bar of the pege is "https://www.example.com/scope/out_scope_redirect". The page sends a fetch request "https://www.example.com/scope/image.png" via the Service Worker. 3. When the user opens "https://www.example.com/scope/in_scope_sw_redirect". The URL bar of the pege is "https://www.example.com/scope/in_scope_sw_redirect". The page sends a fetch request "https://www.example.com/scope/image.png" via the Service Worker. 4. When the user opens "https://www.example.com/scope/out_scope_sw_redirect". The URL bar of the pege is "https://www.example.com/scope/out_scope_sw_redirect". The page sends a fetch request "https://www.example.com/scope/image.png" via the Service Worker. - If the navigation requests of redirect flag is "manual". 1. When the user opens "https://www.example.com/scope/in_scope_redirect". fetch(event.request) returns a "opaqueredirect" response which points to "https://www.example.com/scope/dir/destination". The URL bar of the pege is changed to "https://www.example.com/scope/dir/destination". The page sends a navigation request "https://www.example.com/scope/dir/destination" via the Service Worker. The page sends a fetch request "https://www.example.com/scope/dir/image.png" via the Service Worker. 2. When the user opens "https://www.example.com/scope/out_scope_redirect". fetch(event.request) returns a "opaqueredirect" response which points to "https://www.example.com/out_scope/destination". The URL bar of the pege is changed to "https://www.example.com/out_scope/destination". The page will not be controlled by the Service Worker. The page sends a navigation request "https://www.example.com/out_scope/destination" which is not handled by the Service Worker. The page sends a fetch request "https://www.example.com/out_scope/image.png" which is not handled by the Service Worker. 3. When the user opens "https://www.example.com/scope/in_scope_sw_redirect". The URL bar of the pege is "https://www.example.com/scope/in_scope_sw_redirect". The page sends a fetch request "https://www.example.com/scope/image.png" via the Service Worker. 4. When the user opens "https://www.example.com/scope/out_scope_sw_redirect". The URL bar of the pege is "https://www.example.com/scope/out_scope_sw_redirect". The page sends a fetch request "https://www.example.com/scope/image.png" via the Service Worker. --- Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/101#issuecomment-128245354
Received on Thursday, 6 August 2015 05:19:51 UTC