From 14908140eaaf4a30903973a1970e966e676718ef Mon Sep 17 00:00:00 2001 From: Zae Date: Tue, 30 May 2023 15:22:51 +0800 Subject: [PATCH] Fix `HTTPClient.get_response_body_length()` incorrect on Web --- platform/web/js/libs/library_godot_fetch.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform/web/js/libs/library_godot_fetch.js b/platform/web/js/libs/library_godot_fetch.js index b50012c1e2d..1bb48bfd6a3 100644 --- a/platform/web/js/libs/library_godot_fetch.js +++ b/platform/web/js/libs/library_godot_fetch.js @@ -50,17 +50,22 @@ const GodotFetch = { return; } let chunked = false; + let bodySize = -1; response.headers.forEach(function (value, header) { const v = value.toLowerCase().trim(); const h = header.toLowerCase().trim(); if (h === 'transfer-encoding' && v === 'chunked') { chunked = true; } + if (h === 'content-length') { + bodySize = parseInt(v, 10); + } }); obj.status = response.status; obj.response = response; obj.reader = response.body.getReader(); obj.chunked = chunked; + obj.bodySize = bodySize; }, onerror: function (id, err) {