Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HTML5] Disable body_size in fetch. #47597

Merged
merged 1 commit into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions platform/javascript/js/engine/preloader.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
const Preloader = /** @constructor */ function () { // eslint-disable-line no-unused-vars
function getTrackedResponse(response, load_status) {
let clen = 0;
let compressed = false;
response.headers.forEach(function (value, header) {
const h = header.toLowerCase().trim();
// We can't accurately compute compressed stream length.
if (h === 'content-encoding') {
compressed = true;
} else if (h === 'content-length') {
const length = parseInt(value, 10);
if (!Number.isNaN(length) && length > 0) {
clen = length;
}
}
});
if (!compressed && clen) {
load_status.total = clen;
}
function onloadprogress(reader, controller) {
return reader.read().then(function (result) {
if (load_status.done) {
Expand Down
13 changes: 1 addition & 12 deletions platform/javascript/js/libs/library_godot_fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down