mirror of
https://github.com/godotengine/godot.git
synced 2025-01-24 11:32:51 -05:00
Merge pull request #47597 from Faless/js/4.x_fetch_no_clen
[HTML5] Disable body_size in fetch.
This commit is contained in:
commit
460bef1dab
2 changed files with 1 additions and 29 deletions
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue