From acd538292491a0a9525e50e6f4fb71a87946a4b3 Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Tue, 28 Feb 2023 18:50:42 +0000 Subject: [PATCH] LibWeb/Fetch: Set length synchronously in extract_body Since we don't currently have streams, we didn't set length anywhere. However, this is required by XHR's reliance on Fetch to get the total number of bytes for the progress events. --- Userland/Libraries/LibWeb/Fetch/BodyInit.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp index 8b94dd38bc..076711867f 100644 --- a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp +++ b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp @@ -117,6 +117,10 @@ WebIDL::ExceptionOr extract_body(JS::Realm& realm, })); // FIXME: 11. If source is a byte sequence, then set action to a step that returns source and length to source’s length. + // For now, do it synchronously. + if (source.has()) + length = source.get().size(); + // FIXME: 12. If action is non-null, then run these steps in parallel: // 13. Let body be a body whose stream is stream, source is source, and length is length.