fix: implement ReadableStream fetch body handling (#8855)

This commit is contained in:
Luca Casonato 2020-12-22 14:14:23 +01:00 committed by GitHub
parent 097c3379ba
commit ddda669a02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 2 deletions

View file

@ -1246,8 +1246,12 @@
body = multipartBuilder.getBody();
contentType = multipartBuilder.getContentType();
} else {
// TODO: ReadableStream
throw new Error("Not implemented");
// TODO(lucacasonato): do this in a streaming fashion once we support it
const buf = new Buffer();
for await (const chunk of init.body) {
buf.write(chunk);
}
body = buf.bytes();
}
if (contentType && !headers.has("content-type")) {
headers.set("content-type", contentType);