-
Let first1024Bytes be null.
-
In parallel:
-
Let bytes be the empty byte sequence.
-
Let transformStream be a new TransformStream.
-
Let transformAlgorithm given a chunk be these steps:
-
Enqueue chunk in transformStream.
-
If first1024Bytes is null, then:
-
Let chunkBytes be the result of "get a copy of the bytes held by the buffer source" given chunk.
-
Append chunkBytes to bytes.
-
If bytes's length is greater than 1024, then:
-
Truncate bytes so that it only contains the first 1024 bytes.
-
Set first1024Bytes to bytes.
-
-
-
-
Set up transformStream with transformAlgorithm set to transformAlgorithm.
-
Set response's body's stream to the result of piping response's body's stream through transformStream.
-
-
Wait until first1024Bytes is non-null or response's body's stream is errored.
Created
May 25, 2022 13:39
-
-
Save annevk/ca5475aa173820effdd90b5298bf49c1 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This did not account for unexpected EOF. With that fixed it's now being iterated on in whatwg/fetch#1442.