Skip to content

Commit 9003266

Browse files
authored
Use response's internal response at end of fetch handover
This ensures that callers of processResponseEndOfBody and processResponseConsumeBody receive the correct body and response without additional steps. Closes #1512.
1 parent 6f032a2 commit 9003266

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

fetch.bs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4817,7 +4817,11 @@ steps:
48174817
<a for="fetch params">process response</a> given <var>response</var>, with <var>fetchParams</var>'s
48184818
<a for="fetch params">task destination</a>.
48194819

4820-
<li><p>If <var>response</var>'s <a for=response>body</a> is null, then run
4820+
<li><p>Let <var>internalResponse</var> be <var>response</var>, if <var>response</var> is a
4821+
<a>network error</a>; otherwise <var>response</var>'s
4822+
<a for="filtered response">internal response</a>.
4823+
4824+
<li><p>If <var>internalResponse</var>'s <a for=response>body</a> is null, then run
48214825
<var>processResponseEndOfBody</var>.
48224826

48234827
<li>
@@ -4835,8 +4839,8 @@ steps:
48354839
<a for="TransformStream/set up"><i>flushAlgorithm</i></a> set to
48364840
<var>processResponseEndOfBody</var>.
48374841

4838-
<li><p>Set <var>response</var>'s <a for=response>body</a>'s <a for=body>stream</a> to the result
4839-
of <var>response</var>'s <a for=response>body</a>'s <a for=body>stream</a>
4842+
<li><p>Set <var>internalResponse</var>'s <a for=response>body</a>'s <a for=body>stream</a> to the
4843+
result of <var>internalResponse</var>'s <a for=response>body</a>'s <a for=body>stream</a>
48404844
<a for=ReadableStream>piped through</a> <var>transformStream</var>.
48414845
</ol>
48424846

@@ -4850,18 +4854,19 @@ steps:
48504854
<ol>
48514855
<li><p>Let <var>processBody</var> given <var>nullOrBytes</var> be this step: run
48524856
<var>fetchParams</var>'s <a for="fetch params">process response consume body</a> given
4853-
<var>response</var> and <var>nullOrBytes</var>.
4857+
<var>internalResponse</var> and <var>nullOrBytes</var>.
48544858

48554859
<li><p>Let <var>processBodyError</var> be this step: run <var>fetchParams</var>'s
4856-
<a for="fetch params">process response consume body</a> given <var>response</var> and failure.
4860+
<a for="fetch params">process response consume body</a> given <var>internalResponse</var> and
4861+
failure.
48574862

4858-
<li><p>If <var>response</var>'s <a for=response>body</a> is null, then <a>queue a fetch task</a>
4859-
to run <var>processBody</var> given null, with <var>fetchParams</var>'s
4863+
<li><p>If <var>internalResponse</var>'s <a for=response>body</a> is null, then
4864+
<a>queue a fetch task</a> to run <var>processBody</var> given null, with <var>fetchParams</var>'s
48604865
<a for="fetch params">task destination</a>.
48614866

4862-
<li><p>Otherwise, <a for=body>fully read</a> <var>response</var>'s <a for=response>body</a> given
4863-
<var>processBody</var>, <var>processBodyError</var>, and <var>fetchParams</var>'s
4864-
<a for="fetch params">task destination</a>.
4867+
<li><p>Otherwise, <a for=body>fully read</a> <var>internalResponse</var>'s
4868+
<a for=response>body</a> given <var>processBody</var>, <var>processBodyError</var>, and
4869+
<var>fetchParams</var>'s <a for="fetch params">task destination</a>.
48654870
</ol>
48664871
</ol>
48674872
</div>
@@ -8812,8 +8817,16 @@ particular at what stage you would like to receive a callback:
88128817
<a for=response>body</a> failed, e.g., due to an I/O error.
88138818

88148819
<dt>a <a>byte sequence</a>
8815-
<dd><a for=body>Fully reading</a> the contents of the <a for=/>response</a>'s
8816-
<a for=response>body</a> succeeded.
8820+
<dd>
8821+
<p><a for=body>Fully reading</a> the contents of the <a for=/>response</a>'s
8822+
<a for=response>body</a> succeeded.
8823+
8824+
<p class=warning>A <a>byte sequence</a> containing the full contents will be passed also for a
8825+
<a for=/>request</a> whose <a for=request>mode</a> is "<code>no-cors</code>". Callers have to
8826+
be careful when handling such content, as it should not be accessible to the requesting
8827+
<a for=/>origin</a>. For example, the caller may use contents of a "<code>no-cors</code>"
8828+
<a for=/>response</a> to display image contents directly to the user, but those image contents
8829+
should not be directly exposed to scripts in the embedding document.
88178830
</dl>
88188831

88198832
<div id=example-callback-upon-completion class=example>

0 commit comments

Comments
 (0)