diff --git a/fetch.bs b/fetch.bs index c4c2ff47c..4adafac40 100644 --- a/fetch.bs +++ b/fetch.bs @@ -5961,25 +5961,73 @@ optional boolean forceNewConnection (default false), run these steps:
Return the appropriate network error for fetchParams. -
Let pullAlgorithm be an algorithm that resumes the - ongoing fetch if it is suspended. +
Let |buffer| be an empty buffer that can have bytes appended to it. + +
This represents an internal buffer inside the network layer of the user agent. + +
Let |pullAlgorithm| be the followings steps: + +
Let |promise| be [=a new promise=]. + +
Run the following steps [=in parallel=]: + +
If the size of |buffer| is smaller than a lower limit chosen by the user agent and the + ongoing fetch is [=fetch/suspend|suspended=], [=fetch/resumed|resume=] the fetch. + +
Wait until |buffer| is not empty. + +
[=Queue a fetch task=] to run the following steps, with |fetchParams|'s + [=task destination=]. + +
Let |available| be the size of |buffer|. + +
Let |desiredSize| be |available|. + +
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=]. + +
Let |extractSize| be the smaller value of |available| and |desiredSize|. + +
Let bytes be the result of extracting |extractSize| of bytes from + buffer. + +
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=]. + +
[=ReadableStream/Enqueue=] |view| into |stream|. + +
If |stream| is [=ReadableStream/errored=], then [=fetch controller/terminate=] + |fetchParams|'s [=fetch params/controller=]. + +
[=/Resolve=] |promise| with undefined. +
Return |promise|. +
Let cancelAlgorithm be an algorithm that aborts fetchParams's controller with reason, given reason. -
Let highWaterMark be a non-negative, non-NaN number, chosen by the user agent. - -
Let sizeAlgorithm be an algorithm that accepts a chunk object and returns - a non-negative, non-NaN, non-infinite number, chosen by the user agent. -
Let stream be a new {{ReadableStream}}. -
Set up stream with - pullAlgorithm set to pullAlgorithm, - cancelAlgorithm set to cancelAlgorithm, - highWaterMark set to highWaterMark, and - sizeAlgorithm set to sizeAlgorithm. +
[=ReadableStream/set up with byte reading support|Set up=] |stream| with byte reading + support with [=ReadableStream/set up/pullAlgorithm=] set to |pullAlgorithm|, + [=ReadableStream/set up/cancelAlgorithm=] set to |cancelAlgorithm|.
Set response's body to a new body whose stream is stream. @@ -6033,15 +6081,10 @@ optional boolean forceNewConnection (default false), run these steps:
If bytes is failure, then terminate fetchParams's controller. -
Enqueue a {{Uint8Array}} wrapping an {{ArrayBuffer}} - containing bytes into stream. - -
If stream is errored, then - terminate fetchParams.'s - controller. +
Append |bytes| to |buffer|. -
If stream doesn't need more data ask the user - agent to suspend the ongoing fetch. +
If the size of |buffer| is larger than an upper limit chosen by the user agent, ask + the user agent to [=fetch/suspend=] the ongoing fetch.
Otherwise, if the bytes transmission for response's message body is done @@ -6799,7 +6842,8 @@ steps: running object's get stream.
Otherwise, set stream to a new {{ReadableStream}} object, and - set up stream. + [=ReadableStream/set up with byte reading support|set up=] stream with byte reading + support.
Assert: stream is a {{ReadableStream}} object.