@@ -1879,16 +1879,6 @@ allowed on the resource fetched by looking at the flag of the response returned.
1879
1879
the response of a redirect has to be set if it was set for previous responses in the redirect chain,
1880
1880
this is also tracked internally using the request's <a for=request>timing allow failed flag</a> .
1881
1881
1882
- <p> A <a for=/>response</a> can have an associated
1883
- <dfn export for=response id=concept-response-location-url>location URL</dfn> (null, failure, or a
1884
- <a for=/>URL</a> ). Unless specified otherwise, <a for=/>response</a> has no
1885
- <a for=response>location URL</a> .
1886
-
1887
- <p class="note no-backref"> This concept is used for redirect handling in Fetch and in HTML's
1888
- navigate algorithm. It ensures `<code> Location</code> ` has
1889
- <a lt="extracting header values">its value extracted</a> consistently and only once.
1890
- [[!HTML]]
1891
-
1892
1882
<hr>
1893
1883
1894
1884
<p> A <a for=/>response</a> whose
@@ -2006,6 +1996,36 @@ is a <a>filtered response</a> whose
2006
1996
<p> A <dfn export id=concept-stale-response>stale response</dfn> is a <a for=/>response</a> that is
2007
1997
not a <a>fresh response</a> or a <a>stale-while-revalidate response</a> .
2008
1998
1999
+ <hr>
2000
+
2001
+ <p> The <dfn export for=response id=concept-response-location-url>location URL</dfn> algorithm of
2002
+ given a <a for=/>response</a> <var> response</var> is the following steps. They return null, failure,
2003
+ or a <a for=/>URL</a> .
2004
+
2005
+ <ol>
2006
+ <li><p> If <var> response</var> 's <a for=response>status</a> is not a <a>redirect status</a> , then
2007
+ return null.
2008
+
2009
+ <li><p> Let <var> location</var> be the result of <a>extracting header list values</a> given
2010
+ `<code> Location</code> ` and <var> response</var> 's <a for=response>header list</a> .
2011
+ <!-- https://github.com/whatwg/fetch/issues/814#issuecomment-431366126 -->
2012
+
2013
+ <li>
2014
+ <p> If <var> location</var> is a <a for=header>value</a> , then set <var> location</var> to the result
2015
+ of <a lt="url parser">parsing</a> <var> location</var> with <var> response</var> 's
2016
+ <a for=response>URL</a> .
2017
+
2018
+ <p class=note> If <var> response</var> was constructed through the {{Response}} constructor,
2019
+ <var> response</var> 's <a for=response>URL</a> will be null, meaning that <var> location</var> will
2020
+ only parse successfully if it is an <a>absolute-URL-with-fragment string</a> .
2021
+
2022
+ <li><p> Return <var> location</var> .
2023
+ </ol>
2024
+
2025
+ <p class=note> The <a for=response>location URL</a> algorithm is exclusively used for redirect
2026
+ handling in this standard and in <cite> HTML</cite> 's navigate algorithm which handles redirects
2027
+ manually. [[!HTML]]
2028
+
2009
2029
2010
2030
<h4 id=miscellaneous>Miscellaneous</h4>
2011
2031
@@ -3953,16 +3973,6 @@ optional <i>CORS-preflight flag</i>, run these steps:
3953
3973
3954
3974
<p class=note> 303 is excluded as certain communities ascribe special status to it.
3955
3975
3956
- <li><p> Let <var> location</var> be the result of <a>extracting header list values</a> given
3957
- `<code> Location</code> ` and <var> actualResponse</var> 's <a for=response>header list</a> .
3958
-
3959
- <li><p> If <var> location</var> is a <a for=header>value</a> , then set <var> location</var> to the
3960
- result of <a lt="URL parser">parsing</a> <var> location</var> with <var> actualResponse</var> 's
3961
- <a for=response>URL</a> .
3962
-
3963
- <li><p> Set <var> actualResponse</var> 's
3964
- <a for=response>location URL</a> to <var> location</var> .
3965
-
3966
3976
<li>
3967
3977
<p> Switch on <var> request</var> 's
3968
3978
<a for=request>redirect mode</a> :
@@ -4003,18 +4013,14 @@ optional <i>CORS-preflight flag</i>, run these steps:
4003
4013
<a>filtered response</a> , and <var> response</var> 's
4004
4014
<a for=internal>internal response</a> otherwise.
4005
4015
4006
- <li><p> If <var> actualResponse</var> 's <a for=response>location URL</a>
4007
- is null, then return <var> response</var> .
4016
+ <li><p> Let <var> locationURL</var> be <var> actualResponse</var> 's <a for=response>location URL</a> .
4008
4017
4009
- <li><p> If <var> actualResponse</var> 's <a for=response>location URL</a>
4010
- is failure, then return a <a>network error</a> .
4011
- <!-- only Gecko does this; and even that is currently more complicated -->
4018
+ <li><p> If <var> locationURL</var> is null, then return <var> response</var> .
4012
4019
4013
- <li><p> If <var> actualResponse</var> 's
4014
- <a for=response>location URL</a> 's
4015
- <a for=url>scheme</a> is <em> not</em> an
4016
- <a>HTTP(S) scheme</a> , then return a
4017
- <a>network error</a> .
4020
+ <li><p> If <var> locationURL</var> is failure, then return a <a>network error</a> .
4021
+
4022
+ <li><p> If <var> locationURL</var> 's <a for=url>scheme</a> is not an <a>HTTP(S) scheme</a> , then
4023
+ return a <a>network error</a> .
4018
4024
4019
4025
<li><p> If <var> request</var> 's <a for=request>redirect count</a> is
4020
4026
twenty, return a <a>network error</a> .
@@ -4023,27 +4029,25 @@ optional <i>CORS-preflight flag</i>, run these steps:
4023
4029
<a for=request>redirect count</a> by one.
4024
4030
4025
4031
<li><p> If <var> request</var> 's <a for=request>mode</a> is "<code> cors</code> ",
4026
- <var> actualResponse</var> 's <a for=response>location URL</a>
4027
- <a lt="include credential">includes credentials</a> , and <var> request</var> 's
4028
- <a for=request>origin</a> is not <a>same origin</a> with <var> actualResponse</var> 's
4029
- <a for=response>location URL</a> 's <a for=url>origin</a> , then return a <a>network error</a> .
4032
+ <var> locationURL</var> <a>includes credentials</a> , and <var> request</var> 's
4033
+ <a for=request>origin</a> is not <a>same origin</a> with <var> locationURL</var> 's
4034
+ <a for=url>origin</a> , then return a <a>network error</a> .
4030
4035
4031
4036
<li>
4032
4037
<p> If <var> request</var> 's <a for=request>response tainting</a> is "<code> cors</code> " and
4033
- <var> actualResponse</var> 's <a for=response>location URL</a>
4034
- <a lt="include credential">includes credentials</a> , then return a <a>network error</a> .
4038
+ <var> locationURL</var> <a>includes credentials</a> , then return a <a>network error</a> .
4035
4039
4036
4040
<p class=note> This catches a cross-origin resource redirecting to a same-origin URL.
4037
4041
4038
4042
<li><p> If <var> actualResponse</var> 's <a for=response>status</a> is not 303, <var>request</var>' s
4039
4043
<a for=request>body</a> is non-null, and <var> request</var> 's <a for=request>body</a>' s
4040
4044
<a for=body>source</a> is null, then return a <a>network error</a> .
4041
4045
4042
- <li><p> If <var> actualResponse </var> 's <a for=response>location URL </a>' s <a for=url> origin</a> is
4043
- not <a>same origin</a> with < var> request</var> 's <a for=request>current URL</a>' s
4044
- <a for=url>origin</a> and < var> request</var> 's <a for=request>origin</a> is not <a>same origin</a>
4045
- with <var> request </var> 's < a for=request>current URL</a>' s <a for=url>origin</a> , then set
4046
- <var> request </var> 's < a for=request>tainted origin flag</a> .
4046
+ <li><p> If <var> locationURL </var> 's <a for=url>origin </a> is not <a>same origin</a> with
4047
+ < var> request</var> 's <a for=request>current URL</a>' s <a for=url>origin</a> and
4048
+ <var> request</var> 's <a for=request>origin</a> is not <a>same origin</a> with <var>request</var>' s
4049
+ < a for=request>current URL</a>'s <a for=url>origin</a>, then set <var>request</var>' s
4050
+ <a for=request>tainted origin flag</a> .
4047
4051
4048
4052
<li>
4049
4053
<p> If one of the following is true
@@ -4074,7 +4078,7 @@ optional <i>CORS-preflight flag</i>, run these steps:
4074
4078
<p class="note no-backref"><var> request</var> 's <a for=request>body</a>' s <a for=body>source</a> 's
4075
4079
nullity has already been checked.
4076
4080
4077
- <li><p> Append <var> actualResponse </var> 's <a for=response>location URL</a > to <var>request</var>' s
4081
+ <li><p> <a for=list>Append</a> <var> locationURL </var > to <var> request</var> 's
4078
4082
<a for=request>URL list</a> .
4079
4083
4080
4084
<li><p> Invoke <a>set <var>request</var>'s referrer policy on redirect</a> on <var> request</var> and
0 commit comments