Skip to content

Commit fc6f26f

Browse files
authored
Check chunk type of body's stream when passed to a service worker
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.
1 parent c46ebb9 commit fc6f26f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

fetch.bs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4155,6 +4155,37 @@ these steps:
41554155
<li><p>Let <var>requestForServiceWorker</var> be a <a for=request>clone</a> of
41564156
<var>request</var>.
41574157

4158+
<li>
4159+
<p>If <var>requestForServiceWorker</var>'s <a for=/>body</a> is non-null, then:
4160+
4161+
<ol>
4162+
<li>
4163+
<p>Let <var>transformAlgorithm</var> given <var>chunk</var> be these steps:
4164+
4165+
<ol>
4166+
<li><p>If the ongoing fetch is <a for=fetch>terminated</a>, then abort these steps.
4167+
4168+
<li><p>If <var>chunk</var> is not a {{Uint8Array}} object, then
4169+
<a lt=terminated for=fetch>terminate</a> the ongoing fetch.
4170+
4171+
<li><p>Otherwise, <a for=ReadableStream>enqueue</a> <var>chunk</var>. The user agent may
4172+
split the chunk into <a>implementation-defined</a> practical sizes and
4173+
<a for=ReadableStream>enqueue</a> each of them. The user agent also may concatenate the
4174+
chunks into an <a>implementation-defined</a> practical size and
4175+
<a for=ReadableStream>enqueue</a> it.
4176+
</ol>
4177+
4178+
<li><p>Let <var>transformStream</var> be the result of <a for=TransformStream>setting up</a> a
4179+
{{TransformStream}} with <var>transformAlgorithm</var>.
4180+
4181+
<li><p>Let <var>transformedStream</var> be the result of <var>requestForServiceWorker</var>'s
4182+
<a for=/>body</a>'s <a for=body>stream</a> <a for=ReadableStream>piped through</a>
4183+
<var>transformStream</var>.
4184+
4185+
<li><p>Set <var>requestForServiceWorker</var>'s <a for=/>body</a>'s <a for=body>stream</a> to
4186+
<var>transformedStream</var>.
4187+
</ol>
4188+
41584189
<li><p>Let <var>serviceWorkerStartTime</var> be the <a for=/>coarsened shared current time</a>
41594190
given <var>fetchParams</var>'s <a for="fetch params">cross-origin isolated capability</a>.
41604191

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

0 commit comments

Comments
 (0)