Skip to content

Commit edf07e5

Browse files
authored
Introduce RequestInit's duplex
Require a new duplex member to be set to "half" when request's body is a stream. This makes the semantics clearer for the caller and would allow for a better default in the future. Tests: web-platform-tests/wpt#34496. Closes #1438.
1 parent 50d77e6 commit edf07e5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fetch.bs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6792,6 +6792,7 @@ dictionary RequestInit {
67926792
DOMString integrity;
67936793
boolean keepalive;
67946794
AbortSignal? signal;
6795+
RequestDuplex duplex;
67956796
any window; // can only be set to null
67966797
};
67976798

@@ -6800,6 +6801,7 @@ enum RequestMode { "navigate", "same-origin", "no-cors", "cors" };
68006801
enum RequestCredentials { "omit", "same-origin", "include" };
68016802
enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" };
68026803
enum RequestRedirect { "follow", "error", "manual" };
6804+
enum RequestDuplex { "half" };
68036805
</pre>
68046806

68056807
<p class="note no-backref">"<code>serviceworker</code>" is omitted from
@@ -6888,6 +6890,15 @@ object), initially null.
68886890

68896891
<dt>{{RequestInit/window}}
68906892
<dd>Can only be null. Used to disassociate <var>request</var> from any {{Window}}.
6893+
6894+
<dt>{{RequestInit/duplex}}
6895+
<dd>"<code>half</code>" is the only valid value and it is for initiating a half-duplex fetch
6896+
(i.e., the user agent sends the entire request before processing the response).
6897+
"<code>full</code>" is reserved for future use, for initiating a full-duplex fetch (i.e., the
6898+
user agent can process the response before sending the entire request). This member needs to be
6899+
set when {{RequestInit/body}} is a {{ReadableStream}} object. <span class=note>See
6900+
<a href="https://github.com/whatwg/fetch/issues/1254">issue #1254</a> for defining
6901+
"<code>full</code>".</span>
68916902
</dl>
68926903

68936904
<dt><code><var>request</var> . <a attribute for=Request>method</a></code>
@@ -7318,6 +7329,9 @@ constructor steps are:
73187329
<a for=body>source</a> is null, then:
73197330

73207331
<ol>
7332+
<li><p>If <var>initBody</var> is non-null and <var>init</var>["{{RequestInit/duplex}}"] does
7333+
not <a for=map>exist</a>, then throw a {{TypeError}}.
7334+
73217335
<li><p>If <a>this</a>'s <a for=Request>request</a>'s <a for=request>mode</a> is neither
73227336
"<code>same-origin</code>" nor "<code>cors</code>", then throw a {{TypeError}}.
73237337

0 commit comments

Comments
 (0)