Re: [whatwg/fetch] Remove location URL as field on responses (#1149)

@domenic commented on this pull request.

IMO this should either be "extract a location URL" and take a header list (like "extract a MIME type"), or it should be "response's location URL" (like "response's/request's MIME type"). I prefer the latter.

> @@ -2006,6 +1996,34 @@ is a <a>filtered response</a> whose
 <p>A <dfn export id=concept-stale-response>stale response</dfn> is a <a for=/>response</a> that is
 not a <a>fresh response</a> or a <a>stale-while-revalidate response</a>.
 
+<hr>
+
+<p>To <dfn export id=concept-response-location-url>extract a location URL</dfn>, given a
+<a for=/>response</a> <var>response</var>:
+
+<ol>
+ <li><p>If <var>response</var>'s <a for=response>status</a> is not a <a>redirect status</a>, then
+ return null.
+
+ <li><p>Let <var>location</var> be the result of <a>extracting header list values</a> given
+ `<code>Location</code>` and <var>response</var>'s <a for=response>header list</a>.
+ <!-- https://github.com/whatwg/fetch/issues/814#issuecomment-431366126 -->
+
+ <li>
+  <p>If <var>location</var> is a <a for=header>value</a>, then set <var>location</var> to the result

"extracting header list values" returns a list, not a value, if I am reading this right?

> +
+<p>To <dfn export id=concept-response-location-url>extract a location URL</dfn>, given a
+<a for=/>response</a> <var>response</var>:
+
+<ol>
+ <li><p>If <var>response</var>'s <a for=response>status</a> is not a <a>redirect status</a>, then
+ return null.
+
+ <li><p>Let <var>location</var> be the result of <a>extracting header list values</a> given
+ `<code>Location</code>` and <var>response</var>'s <a for=response>header list</a>.
+ <!-- https://github.com/whatwg/fetch/issues/814#issuecomment-431366126 -->
+
+ <li>
+  <p>If <var>location</var> is a <a for=header>value</a>, then set <var>location</var> to the result
+  of <a lt="url parser">parsing</a> <var>location</var> with <var>response</var>'s
+  <a for=response>URL</a>.

The URL parser takes an optional base URL, not a URL-or-null. So it'd be most correct to state this as something like "parsing _location_, with _response_'s URL if _response_'s URL is not null."

> + <!-- https://github.com/whatwg/fetch/issues/814#issuecomment-431366126 -->
+
+ <li>
+  <p>If <var>location</var> is a <a for=header>value</a>, then set <var>location</var> to the result
+  of <a lt="url parser">parsing</a> <var>location</var> with <var>response</var>'s
+  <a for=response>URL</a>.
+
+  <p class=note>If <var>response</var> was constructed in a service worker <var>response</var>'s
+  <a for=response>URL</a> will be null, meaning that <var>location</var> will only parse
+  successfully if it is an <a>absolute-URL-with-fragment string</a>.
+
+ <li><p>Return <var>location</var>.
+</ol>
+
+<p class="note no-backref"><a>Extract a location URL</a> is used for redirect handling in Fetch and
+in HTML's navigate algorithm as it handles redirects manually. [[!HTML]]

`<cite>` around names of standards?

-- 
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/pull/1149#pullrequestreview-579505840

Received on Friday, 29 January 2021 18:23:50 UTC