<platinum-sw-register ... >
<platinum-sw-fetch handler="doNativeFetch" path="/myservice(.*)"></platinum-sw-fetch>
.
.
.
</platinum-sw-register>
var doNativeFetch = function doNativeFetch(request, values, options) {
console.log('doNativeFetch request', request, values, options);
return fetch(request);
};
This works as expected for GET requests. I see GET request to "/myservice/..." logged by my custome doNativeFetch handler, the service worker doesn't cache these requests as expected. Http PUT requests also work (from the clients perspective) but they do *not* appear to be directed to my doNativeFetch handler - I never see my "doNativeFetch" log message. This causes a problem when my server returns an 409 status to a PUT request (in response to a client's attempt to write state data). My application code expectes to handle this 409 error when it occurs. But I never see the error when I run with the platinum-sw service worker enabled. Instead I see the following in Chrome's console:
(Here is clients http request)
XHR finished loading: PUT "https://abc.example.com/myservice/12345".
(Immediately followed by this, which appears to be the service layer intercept, no my doNativeFetch handler).
PUT https://abc.example.com/myservice/12345 409 (OK) <<< expected, good so far!
The FetchEvent for "https://abc.example.com/myservice/12345" resulted in a network error response: an object that was not a Response was passed to respondWith() <<< the 409 is not passed-thru, where do I hook into respondWith?
(Immediately followed by this, which is my client layer code getting a net::ERR_FAILED rather than the 409 http response - bad!).
PUT https://abc.example.com/myservice/12345 net::ERR_FAILED <<<< problem, client doesn't get the 409
... after much digging, I am a loss as to how to proceed with this. The most basic issue is that my custom platinum-sw-fetch handler is never called for the PUT request. How to I configure a platinum-sw-fetch handler that will intercept a PUT request and allow me to pass a 409 error through to the calling client? Or is that the wrong stategy entirely? Perhaps somewhere I provide a FetchEvent.respondWith implementation? But where and how?