web/fetch: use estimated-content-length if content-length is unavailable

This commit is contained in:
jj 2025-04-23 16:44:49 +00:00
parent 37a71837a7
commit d1bb1764df
No known key found for this signature in database

View File

@ -31,8 +31,11 @@ const fetchFile = async (url: string) => {
return error("file response wasn't ok"); return error("file response wasn't ok");
} }
const contentType = response.headers.get('Content-Type') || 'application/octet-stream'; const contentType = response.headers.get('Content-Type')
const contentLength = response.headers.get('Content-Length'); || 'application/octet-stream';
const contentLength = response.headers.get('Content-Length')
|| response.headers.get('Estimated-Content-Length');
const totalBytes = contentLength ? parseInt(contentLength, 10) : null; const totalBytes = contentLength ? parseInt(contentLength, 10) : null;
const reader = response.body?.getReader(); const reader = response.body?.getReader();