Skip to content

Commit 0f29092

Browse files
authored
Give all bodies a stream
This simplifies some wording introduced in #425 and aligns it with the recently introduced cloning for service workers. Fixes #1176.
1 parent 00344d2 commit 0f29092

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

fetch.bs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,7 @@ worked on in <a href=https://github.com/whatwg/fetch/issues/1156>issue #1156</a>
10011001
<p>A <dfn export id=concept-body>body</dfn> consists of:
10021002

10031003
<ul>
1004-
<li><p>A <dfn export for=body id=concept-body-stream>stream</dfn> (null or a {{ReadableStream}}
1005-
object).
1004+
<li><p>A <dfn export for=body id=concept-body-stream>stream</dfn> (a {{ReadableStream}} object).
10061005

10071006
<li><p>A <dfn export for=body id=concept-body-transmitted>transmitted bytes</dfn>
10081007
(an integer), initially 0.
@@ -4105,30 +4104,21 @@ steps. They return a <a for=/>response</a>.
41054104
<p>Otherwise:
41064105

41074106
<ol>
4108-
<li><p>Set <var>httpRequest</var> to a copy of <var>request</var> except for its
4109-
<a for=request>body</a>.
4110-
4111-
<li><p>Let <var>body</var> be <var>request</var>'s <a for=request>body</a>.
4112-
4113-
<li><p>Set <var>httpRequest</var>'s <a for=request>body</a> to <var>body</var>.
4107+
<li>
4108+
<p>Set <var>httpRequest</var> to a <a for=request>clone</a> of <var>request</var>.
41144109

4115-
<li><p>If <var>body</var> is non-null, then set <var>request</var>'s <a for=request>body</a> to
4116-
a new <a for=/>body</a> whose <a for=body>stream</a> is null and whose <a for=body>source</a>
4117-
is <var>body</var>'s <a for=body>source</a>.
4110+
<p class=note>Implementations are encouraged to avoid teeing <var>request</var>'s
4111+
<a for=request>body</a>'s <a for=body>stream</a> when <var>request</var>'s
4112+
<a for=request>body</a>'s <a for=body>source</a> is null as only a single body is needed in
4113+
that case. E.g., when <var>request</var>'s <a for=request>body</a>'s <a for=body>source</a>
4114+
is null, redirects and authentication will end up failing the fetch.
41184115

41194116
<li><p>Set <var>httpFetchParams</var> to a copy of <var>fetchParams</var>.
41204117

41214118
<li><p>Set <var>httpFetchParams</var>'s <a for="fetch params">request</a> to
41224119
<var>httpRequest</var>.
41234120
</ol>
41244121

4125-
<p class="note no-backref"><var>request</var> is copied as <var>httpRequest</var> here as we
4126-
need to be able to add headers to <var>httpRequest</var> and read its <a for=request>body</a>
4127-
without affecting <var>request</var>. Namely, <var>request</var> can be reused with redirects,
4128-
authentication, and proxy authentication. We copy rather than clone in order to reduce memory
4129-
consumption. In case <var>request</var>'s <a for=request>body</a>'s <a for=body>source</a> is
4130-
null, redirects and authentication will end up failing the fetch.
4131-
41324122
<li>
41334123
<p>Let <var>includeCredentials</var> be true if one of
41344124

0 commit comments

Comments
 (0)