[whatwg/fetch] response.ok = false for opaque responses may be misleading (#299)

When making a cross-domain fetch one may receive a response with `response.type === 'opaque'`.
Currently this seems to mean (at least in Chrome) that `response.ok` is `false` _even if the response succeeded_.

The current spec does not appear to specify what the value for `response.ok` should be in this situation ([see the spec here](https://fetch.spec.whatwg.org/#concept-filtered-response-opaque)), while it does specify other values like `response.status` being `0`). The [docs on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Response/ok) also do not discuss the value in opaque cases (or that they are even a possibility).

I feel that a `response.ok` value of `false` is misleading and may catch other people out who are not aware of the meaning of opaque responses. As for what the value should be, I'm not sure. A value of `true` may also be equally misleading. A value of `null` might be better, but still has potential for issues for people naively checking for `ok` like most examples do.

For those just looking for a code solution, here is one way to catch this case:

      if (response.type === 'opaque' || response.ok) {
        return response;
      } else {
        // do something else
      }

Thanks!

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/299

Received on Thursday, 5 May 2016 14:17:25 UTC