Fixed XHR uploads

This commit is contained in:
Eduard Urbach 2018-04-17 14:57:09 +02:00
parent 0856fc209a
commit 0a0cbf6467

View File

@ -106,7 +106,14 @@ class MyServiceWorker {
// onRequest intercepts all browser requests // onRequest intercepts all browser requests
onRequest(evt: FetchEvent) { onRequest(evt: FetchEvent) {
return evt.respondWith(this.fromNetwork(evt.request)) // Allow XHR upload requests via POST,
// so that we can receive upload progress events.
if(evt.request.method === "POST") {
return
}
// Fetch via network
return evt.respondWith(fetch(evt.request))
// let request = evt.request as Request // let request = evt.request as Request
@ -345,10 +352,6 @@ class MyServiceWorker {
}) })
}) })
} }
fromNetwork(request): Promise<Response> {
return fetch(request)
}
} }
// MyCache is the cache used by the service worker. // MyCache is the cache used by the service worker.