Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bytes() method to Body mixin #1753

Merged
merged 1 commit into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -7162,6 +7162,7 @@ interface mixin Body {
readonly attribute boolean bodyUsed;
[NewObject] Promise<ArrayBuffer> arrayBuffer();
[NewObject] Promise<Blob> blob();
[NewObject] Promise<Uint8Array> bytes();
[NewObject] Promise<FormData> formData();
[NewObject] Promise<any> json();
[NewObject] Promise<USVString> text();
Expand Down Expand Up @@ -7195,6 +7196,9 @@ due course.
<dt><code><var>requestOrResponse</var> . <a method for=Body>blob</a>()</code>
<dd><p>Returns a promise fulfilled with <var>requestOrResponse</var>'s body as {{Blob}}.

<dt><code><var>requestOrResponse</var> . <a method for=Body>bytes</a>()</code>
<dd><p>Returns a promise fulfilled with <var>requestOrResponse</var>'s body as {{Uint8Array}}.

<dt><code><var>requestOrResponse</var> . <a method for=Body>formData</a>()</code>
<dd><p>Returns a promise fulfilled with <var>requestOrResponse</var>'s body as {{FormData}}.

Expand Down Expand Up @@ -7290,6 +7294,15 @@ and whose {{Blob/type}} attribute is the result of <a for=Body>get the MIME type
<!-- This is wrong. It should really set an underlying concept to this. -->
</div>

<div algorithm>
<p>The <dfn method for=Body><code>bytes()</code></dfn> method steps are to return the result
of running <a for=Body>consume body</a> with <a>this</a> and the following step given a
<a for=/>byte sequence</a> <var>bytes</var>: return the result of [=ArrayBufferView/create|creating=] a
{{Uint8Array}} from <var>bytes</var> in <a>this</a>'s <a>relevant realm</a>.

<p class="note">The above method can reject with a {{RangeError}}.
</div>

<div algorithm>
<p>The <dfn method for=Body><code>formData()</code></dfn> method steps are to return the result of
running <a for=Body>consume body</a> with <a>this</a> and the following steps given a
Expand Down
Loading