1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:17:45 +00:00

LibWeb: Implement a slightly better ad-hoc Body::clone method

Just creating a stream on the JS heap isn't enough, as we will later
crash when trying to read from that stream as it hasn't been properly
initialized. Instead, until we have teeing implemented (which is a
rather huge part of the Streams spec), create streams using proper AOs
that do initialize the stream.
This commit is contained in:
Timothy Flynn 2024-01-27 09:16:09 -05:00 committed by Andreas Kling
parent c8c3866101
commit 9272d185ad
3 changed files with 34 additions and 2 deletions

View file

@ -0,0 +1,17 @@
<script src="../include.js"></script>
<script>
asyncTest(async done => {
fetch("./../basic.html", { mode: "no-cors" })
.then(response => {
const clonedResponse = response.clone();
return clonedResponse.body;
})
.then(body => {
const reader = body.getReader();
reader.read();
println("Was able to create a reader from a cloned Fetch response!");
done();
});
});
</script>