From ddda669a02fa394627dda2ac3d7ea0ed8830b920 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 22 Dec 2020 14:14:23 +0100 Subject: fix: implement ReadableStream fetch body handling (#8855) --- op_crates/fetch/26_fetch.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'op_crates/fetch/26_fetch.js') diff --git a/op_crates/fetch/26_fetch.js b/op_crates/fetch/26_fetch.js index 95ee96812..0835e12a1 100644 --- a/op_crates/fetch/26_fetch.js +++ b/op_crates/fetch/26_fetch.js @@ -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); -- cgit v1.2.3