Re: [whatwg/fetch] Set body with byte reading support (PR #1593)

@saschanaz commented on this pull request.



> +   <li>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>Let |extractSize| be the smaller value of |available| and |desiredSize|.
+
+   <li>Let <var>bytes</var> be the result of extracting |extractSize| of bytes from
+   <var>buffer</var>.
+
+   <li>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>[=ReadableStream/Enqueue=] |view| into |stream|.

Isn't it something recommended by Streams? Below https://streams.spec.whatwg.org/#readablestream-current-byob-request-view:

>Specifications should, when possible, [write](https://webidl.spec.whatwg.org/#arraybufferview-write) into the [current BYOB request view](https://streams.spec.whatwg.org/#readablestream-current-byob-request-view) when it is non-null, and then call [enqueue](https://streams.spec.whatwg.org/#readablestream-enqueue) with that view.

It doesn't have a separate algorithm for `respond`, so I think enqueuing is the only way to ping the stream...

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/pull/1593#discussion_r1083738368
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/pull/1593/review/1265131297@github.com>

Received on Monday, 23 January 2023 08:05:34 UTC