Skip to content

Commit

Permalink
Check chunk type of body's stream when passed to a service worker
Browse files Browse the repository at this point in the history
This change addresses the inconsistency discussed in #267 that a chunk type in a stream body on uploading to the network is limited to Uint8Array, but passing it to a service worker is not restricted. This change limits the latter as well.

Tests: web-platform-tests/wpt#28203.
  • Loading branch information
yoichio authored Apr 15, 2021
1 parent c46ebb9 commit fc6f26f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4155,6 +4155,37 @@ these steps:
<li><p>Let <var>requestForServiceWorker</var> be a <a for=request>clone</a> of
<var>request</var>.

<li>
<p>If <var>requestForServiceWorker</var>'s <a for=/>body</a> is non-null, then:

<ol>
<li>
<p>Let <var>transformAlgorithm</var> given <var>chunk</var> be these steps:

<ol>
<li><p>If the ongoing fetch is <a for=fetch>terminated</a>, then abort these steps.

<li><p>If <var>chunk</var> is not a {{Uint8Array}} object, then
<a lt=terminated for=fetch>terminate</a> the ongoing fetch.

<li><p>Otherwise, <a for=ReadableStream>enqueue</a> <var>chunk</var>. The user agent may
split the chunk into <a>implementation-defined</a> practical sizes and
<a for=ReadableStream>enqueue</a> each of them. The user agent also may concatenate the
chunks into an <a>implementation-defined</a> practical size and
<a for=ReadableStream>enqueue</a> it.
</ol>

<li><p>Let <var>transformStream</var> be the result of <a for=TransformStream>setting up</a> a
{{TransformStream}} with <var>transformAlgorithm</var>.

<li><p>Let <var>transformedStream</var> be the result of <var>requestForServiceWorker</var>'s
<a for=/>body</a>'s <a for=body>stream</a> <a for=ReadableStream>piped through</a>
<var>transformStream</var>.

<li><p>Set <var>requestForServiceWorker</var>'s <a for=/>body</a>'s <a for=body>stream</a> to
<var>transformedStream</var>.
</ol>

<li><p>Let <var>serviceWorkerStartTime</var> be the <a for=/>coarsened shared current time</a>
given <var>fetchParams</var>'s <a for="fetch params">cross-origin isolated capability</a>.

Expand Down Expand Up @@ -7828,6 +7859,7 @@ Xabier Rodríguez,
Yehuda Katz,
Yoav Weiss,
Youenn Fablet<!-- youennf; GitHub -->,
Yoichi Osato,
平野裕 (Yutaka Hirano), and
Zhenbin Xu
for being awesome.
Expand Down

0 comments on commit fc6f26f

Please sign in to comment.