[whatwg/fetch] Clarify response's url list state when parsing a 3xx response's Location header value (#631)

I'm trying to figure out the algorithm Fetch specifies for following redirects, but keep stumbling over whether or not the 3xx response's Location header is parsed relative to a base url. The Fetch spec implies it is parsed with the response's url as its base:

[Fetch section 4.3, step 5](https://fetch.spec.whatwg.org/#http-fetch):
> 5. If actualResponse’s status is a redirect status, then run these substeps:
      1. [...]
      2. Let location be the result of extracting header list values given `Location` and actualResponse’s header list.
      3. If location is a value, then set location to the result of parsing location with actualResponse’s url.

where "actualResponse's url" means the last response url in the response's url list. However, at the point in the algorithm I'm describing, I don't see how the response's url list can be anything other than null, which seems to imply that we're supposed to parse the Location header as an absolute url. That seems to contradict RFC 7231's definition of the Location header value:

[RFC7231, section 7.1.2](https://tools.ietf.org/html/rfc7231#section-7.1.2):
> The field value consists of a single URI-reference.  When it has the
   form of a relative reference ([RFC3986], Section 4.2), the final
   value is computed by resolving it against the effective request URI
   ([RFC3986], Section 5).

The situation I'm considering involves fetches originating from a service worker script, requesting resources from the same origin as the service worker's registration. The Location header parsing described above happens in the HTTP fetch algorithm [Fetch section 4.3](https://fetch.spec.whatwg.org/#http-fetch) which is ultimately called from step 5 of the main fetch algorithm ([Fetch section 4.1](https://fetch.spec.whatwg.org/#main-fetch)). However, the response's url list is only ever set in step 9 of the main fetch algorithm ("If internalResponse’s url list is empty, then set it to a copy of request’s url list."), long after the response's Location header is supposed to have been parsed. [Fetch section 2.2.6](https://fetch.spec.whatwg.org/#responses) says about the url list, "Unless stated otherwise, it is the empty list."

Am I interpreting something incorrectly? Or perhaps there's another specification which covers when a response's url list is set? I'd appreciate any clarification. 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/631

Received on Wednesday, 15 November 2017 00:55:24 UTC