mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
fix(op_crates/fetch): Body.body should be stream of Uint8Array (#8030)
This commit is contained in:
parent
35028db5e5
commit
08441b855d
2 changed files with 4 additions and 2 deletions
|
@ -133,6 +133,7 @@ unitTest({ perms: { net: true } }, async function fetchAsyncIterator(): Promise<
|
||||||
assert(response.body !== null);
|
assert(response.body !== null);
|
||||||
let total = 0;
|
let total = 0;
|
||||||
for await (const chunk of response.body) {
|
for await (const chunk of response.body) {
|
||||||
|
assert(chunk instanceof Uint8Array);
|
||||||
total += chunk.length;
|
total += chunk.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,12 +146,13 @@ unitTest({ perms: { net: true } }, async function fetchBodyReader(): Promise<
|
||||||
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
|
||||||
const headers = response.headers;
|
const headers = response.headers;
|
||||||
assert(response.body !== null);
|
assert(response.body !== null);
|
||||||
const reader = await response.body.getReader();
|
const reader = response.body.getReader();
|
||||||
let total = 0;
|
let total = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
const { done, value } = await reader.read();
|
const { done, value } = await reader.read();
|
||||||
if (done) break;
|
if (done) break;
|
||||||
assert(value);
|
assert(value);
|
||||||
|
assert(value instanceof Uint8Array);
|
||||||
total += value.length;
|
total += value.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -786,7 +786,7 @@
|
||||||
|
|
||||||
this._stream = new ReadableStream({
|
this._stream = new ReadableStream({
|
||||||
start(controller) {
|
start(controller) {
|
||||||
controller.enqueue(buf);
|
controller.enqueue(new Uint8Array(buf));
|
||||||
controller.close();
|
controller.close();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue