Re: [whatwg/fetch] Formalize reading bodies (#1172)

@domenic commented on this pull request.



> +<p>To <dfn export for=body>fully read</dfn> a <a for=/>body</a> <var>body</var>, given an algorithm
+<dfn export for="body/fully read"><var>processBody</var></dfn>, an optional algorithm
+<dfn export for="body/fully read"><var>processError</var></dfn>, and an optional null or
+<a for=/>global object</a> <dfn export for="body/fully read">taskDestination</dfn> (default null),
+run these steps:
+
+<ol>
+ <li><p>If <var>taskDestination</var> is null, then set <var>taskDestination</var> to the result of
+ <a>starting a new parallel queue</a>.
+
+ <li><p>Let <var>promise</var> be the result of <a>fully reading body as promise</a> given
+ <var>body</var>.
+
+ <li><p>Let <var>fulfilledSteps</var> given a <a>byte sequence</a> <var>bytes</var> be to
+ <a>queue a fetch task</a> to run <var>processBody</var> given <var>bytes</var>, with
+ <var>taskDestination</var>.

fulfilledSteps and stream's chunk steps/close steps/error steps run as microtasks, on the stream object's relevant agent's event loop. So if you're happy with that event loop and that task priority, you don't need to queue a fetch task. You could do so if you want to switch event loops or change task priorities.

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

Received on Wednesday, 17 February 2021 15:36:27 UTC