diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-04-03 14:51:54 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-04-03 15:05:36 +0200 |
commit | 737ed0f66ea2f5351b440c4a387091c5374758b3 (patch) | |
tree | 47210085eafe29a210eeec408679d0c1e90b0367 /platform/javascript/js/libs | |
parent | ed2f51b15fee22a35d2a975fd77a70fc291bd8de (diff) |
[HTML5] Disable body_size in fetch.
We were using `Content-Length` from the server when `Content-Encoding`
was not set (i.e. response was not compressed).
Sadly, in CORS requests accessing headers is restricted, and while
`Content-Length` is enabled by default, `Content-Encoding` is not.
This results in the impossibility of knowing if the content was
compressed, unless the server explicitly enabled the encoding header
via `Access-Control-Expose-Headers`.
To keep maximum compatibility we must disable `body_size` completely.
Diffstat (limited to 'platform/javascript/js/libs')
-rw-r--r-- | platform/javascript/js/libs/library_godot_fetch.js | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/platform/javascript/js/libs/library_godot_fetch.js b/platform/javascript/js/libs/library_godot_fetch.js index 4ae6a23593..de5ae2b1ae 100644 --- a/platform/javascript/js/libs/library_godot_fetch.js +++ b/platform/javascript/js/libs/library_godot_fetch.js @@ -49,25 +49,14 @@ const GodotFetch = { if (!obj) { return; } - let size = -1; - let compressed = false; let chunked = false; response.headers.forEach(function (value, header) { const v = value.toLowerCase().trim(); const h = header.toLowerCase().trim(); - if (h === 'content-encoding') { - compressed = true; - size = -1; - } else if (h === 'content-length') { - const len = Number.parseInt(value, 10); - if (!Number.isNaN(len) && !compressed) { - size = len; - } - } else if (h === 'transfer-encoding' && v === 'chunked') { + if (h === 'transfer-encoding' && v === 'chunked') { chunked = true; } }); - obj.bodySize = size; obj.status = response.status; obj.response = response; obj.reader = response.body.getReader(); |