Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
noamr committed Nov 7, 2021
1 parent 5c19df6 commit 46b1a53
Showing 1 changed file with 51 additions and 31 deletions.
82 changes: 51 additions & 31 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3819,15 +3819,24 @@ the request.
<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>Origin</code>`, `<code>User-Agent</code>`, `<code>Referer</code>`,
or `<code>Cache-Control</code>`, set <var>hasCustomHeaders</var> to true.
`<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>

<li><p><var>request</var>'s <a for=request>URL</a>'s <a for=url>scheme</a> is an
<a>HTTP(S) scheme</a>

<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
Expand All @@ -3839,14 +3848,21 @@ the request.

<ol>
<li><p>Let <var>preloadedResponse</var> be the result of invoking
<span>consume a preloaded resource</span> for <var>request</var>'s <a for=request>window</a>,
with <var>request</var>'s <a for=request>URL</a>, <var>request</var>'s <a for=request>origin</a>,
<var>request</var>'s <a for=request>destination</a>, <var>request</var>'s
<a for=request>mode</a>, <var>request</var>'s <a for=request>credentials mode</a>, and
<var>request</var>'s <a for=request>integrity metadata</a>.

<li><p>If <var>preloadedResponse</var> is not null, then run <a>fetch finale</a> with
<var>preloadedResponse</var> and <var>fetchParams</var>, and return.
<span>consume a preloaded resource</span> given <var>request</var>'s <a for=request>window</a>,
with <var>req</var>'s <a for=request>URL</a>, <var>req</var>'s <a for=request>destination</a>,
<var>req</var>'s <a for=request>mode</a>, and <var>req</var>'s
<a for=request>credentials mode</a>.

<li>
<p>If <var>preloadedResponse</var> is not null, then run this step <a>in parallel</a> and
return: <a>Verify response integrity</a> given <var>preloadedResponse</var>,
<var>fetchParams</var>, and <var>req</var>'s <a for=request>integrity metadata</a>.

<p class=note>Some preloaded resources might have previously verified their data integrity, and
user-agents can optimize by relying on that prior verification. The behavior in that case is
expected to be equivalent to re-verifying the preloaded response with the consumer request's
<a for=request>integrity metadata</a>.
</li>
</ol>
</li>

Expand Down Expand Up @@ -4183,37 +4199,41 @@ steps:

<p class=note>This standardizes the error handling for servers that violate HTTP.

<li>
<p>If <var>request</var>'s <a for=request>integrity metadata</a> is not the empty string, then:
<li><p><a>Verify response integrity</a> given <var>response</var>, with <var>fetchParams</var>, and
<var>request</var>'s <a for=request>integrity metadata</a>.
</ol>

<ol>
<li><p>Let <var>processBodyError</var> be this step: run <a>fetch finale</a> given
<var>fetchParams</var> and a <a>network error</a>.
<p>To <dfn>verify response integrity</dfn> given <a for=/>response</a> <var>response</var>,
<a for=/>fetch params</a> <var>fetchParams</var> and string <var>integrityMetadata</var>, run these
steps:

<ol>
<li><p>If <var>integrityMetadata</var> is an empty string, then run <a>fetch finale</a> given
<var>fetchParams</var> and <var>response</var>, and return.

<li><p>If <var>request</var>'s <a for=request>response tainting</a> is "<code>opaque</code>",
<var>response</var> is a <a>network error</a>, or <var>response</var>'s <a for=response>body</a>
is null, then run <var>processBodyError</var> and abort these steps.
<li><p>Let <var>processBodyError</var> be this step: run <a>fetch finale</a> given
<var>fetchParams</var> and a <a>network error</a>.

<li>
<p>Let <var>processBody</var> given <var>bytes</var> be these steps:
<li><p>If <var>request</var>'s <a for=request>response tainting</a> is "<code>opaque</code>",
<var>response</var> is a <a>network error</a>, or <var>response</var>'s <a for=response>body</a>
is null, then run <var>processBodyError</var> and abort these steps.

<ol>
<li><p>If <var>bytes</var> do not <a lt="Do bytes match metadataList?">match</a>
<var>request</var>'s <a for=request>integrity metadata</a>, then run
<var>processBodyError</var> and abort these steps. [[!SRI]]
<li>
<p>Let <var>processBody</var> given <var>bytes</var> be these steps:

<li><p>Set <var>response</var>'s <a for=response>body</a> to the first return value of
<a for=BodyInit>safely extracting</a> <var>bytes</var>.
<ol>
<li><p>If <var>bytes</var> do not <a lt="Do bytes match metadataList?">match</a>
<var>request</var>'s <a for=request>integrity metadata</a>, then run
<var>processBodyError</var> and abort these steps. [[!SRI]]

<li><p>Run <a>fetch finale</a> given <var>fetchParams</var> and <var>response</var>.
</ol>
<li><p>Set <var>response</var>'s <a for=response>body</a> to the first return value of
<a for=BodyInit>safely extracting</a> <var>bytes</var>.

<li><p><a for=body>Fully read</a> <var>response</var>'s <a for=response>body</a> given
<var>processBody</var> and <var>processBodyError</var>.
<li><p>Run <a>fetch finale</a> given <var>fetchParams</var> and <var>response</var>.
</ol>

<li><p>Otherwise, run <a>fetch finale</a> given <var>fetchParams</var> and <var>response</var>.
<li><p><a for=body>Fully read</a> <var>response</var>'s <a for=response>body</a> given
<var>processBody</var> and <var>processBodyError</var>.
</ol>

<hr>
Expand Down

0 comments on commit 46b1a53

Please sign in to comment.