Re: [whatwg/fetch] Integration with preload (PR #1342)

@noamr commented on this pull request.



> @@ -3811,6 +3814,54 @@ the request.
  <var>request</var>'s <a for=request>origin</a> to  <var>request</var>'s <a for=request>client</a>'s
  <a for="environment settings object">origin</a>.
 
+ <li><p>Let <var>hasCustomHeaders</var> be false.
+
+ <li><p><a for=list>For each</a> <var>header</var> in <var>request</var>'s
+ <a for=request>header list</a>, if <var>header</var>'s <a for=header>name</a> is
+ not `<code>If-Modified-Since</code>`, `<code>If-None-Match</code>`, `<code>If-Unmodified-Since</code>`,
+ `<code>If-Match</code>`, `<code>User-Agent</code>`, or `<code>Cache-Control</code>`, set
+ <var>hasCustomHeaders</var> to true.

How come?
Anyway, maybe we should avoid `hasCustomHeaders` at all, and Let `fetch()` set `allow preloads` to false if there are user-defined headers.

> + <li><p>Let <var>hasCustomHeaders</var> be false.
+
+ <li><p><a for=list>For each</a> <var>header</var> in <var>request</var>'s
+ <a for=request>header list</a>, if <var>header</var>'s <a for=header>name</a> is
+ not `<code>If-Modified-Since</code>`, `<code>If-None-Match</code>`, `<code>If-Unmodified-Since</code>`,
+ `<code>If-Match</code>`, `<code>User-Agent</code>`, or `<code>Cache-Control</code>`, set
+ <var>hasCustomHeaders</var> to true.
+
+ <li>
+  <p>If all of the following conditions are true:</p>
+
+  <ul class=brief>
+   <li><p><var>request</var>'s <a for=request>allow preloads</a> is true
+
+   <li><p><var>request</var>'s <a for=request>origin</a> is <var>request</var>'s
+   <a for=request>client</a>'s <a for="environment settings object">origin</a>

It's theoretically possible to call fetch with a different origin, the only place where I found this to happen is [Process a navigate fetch](https://html.spec.whatwg.org/#process-a-navigate-fetch) which is not relevant for preloads. Maybe this can be an assert?

> +   <li><p><var>request</var>'s <a for=request>mode</a> is "<code>same-origin</code>",
+   "<code>cors</code>", or "<code>no-cors</code>"
+
+   <li><p><var>hasCustomHeaders</var> is false
+
+   <li><p><var>request</var>'s <a for=request>window</a> is not null
+
+   <li><p><var>request</var>'s <a for=request>method</a> is `<code>GET</code>`
+  </ul>
+
+  <p>then perform the following steps:
+
+  <ol>
+   <li><p>Let <var>onPreloadedResponseAvailable</var> be to an algorithm that runs the following
+   step <a>in parallel</a> given <a for=/>response</a> <var>response</var>:
+   Run <a>fetch finale</a> given <var>response</var> and <var>fetchParams</var>.

OK

-- 
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/1342#discussion_r761892664

Received on Friday, 3 December 2021 12:28:19 UTC