Skip to content

Editorial: Use "pull from bytes" algorithm #1628

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

Merged
merged 1 commit into from
Apr 28, 2023
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
25 changes: 2 additions & 23 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -6110,7 +6110,7 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
</ol>

<li>
<p>Let |buffer| be an empty buffer that can have bytes appended to it.
<p>Let |buffer| be an empty [=byte sequence=].

<p class="note">This represents an internal buffer inside the network layer of the user agent.

Expand All @@ -6134,28 +6134,7 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
[=task destination=].

<ol>
<li><p>Let |available| be the size of |buffer|.

<li><p>Let |desiredSize| be |available|.

<li><p>If |stream|'s [=ReadableStream/current BYOB request view=] is non-null, then set
|desiredSize| to |stream|'s [=ReadableStream/current BYOB request view=]'s
[=BufferSource/byte length=].

<li><p>Let |extractSize| be the smaller value of |available| and |desiredSize|.

<li><p>Let <var>bytes</var> be the result of extracting |extractSize| of bytes from
<var>buffer</var>.

<li><p>If |stream|s [=ReadableStream/current BYOB request view=] is non-null, then
[=ArrayBufferView/write=] |bytes| into |stream|'s
[=ReadableStream/current BYOB request view=], and set |view| to |stream|'s
[=ReadableStream/current BYOB request view=].

<li>Otherwise, set |view| to the result of [=ArrayBufferView/create|creating=] a
{{Uint8Array}} from |bytes| in |stream|'s [=relevant Realm=].

<li><p>[=ReadableStream/Enqueue=] |view| into |stream|.
<li><p>[=ReadableStream/Pull from bytes=] |buffer| into |stream|.

<li><p>If |stream| is [=ReadableStream/errored=], then [=fetch controller/terminate=]
|fetchParams|'s [=fetch params/controller=].
Expand Down