Check for encoded content
This commit is contained in:
parent
ad85f537ac
commit
d8a90544d7
|
@ -3,9 +3,10 @@ export type onProgress = (percent: number, total: number) => void;
|
||||||
export const fetchWithProgress = async (url: string, onProgress?: onProgress, signal?: AbortSignal): Promise<ArrayBuffer> => {
|
export const fetchWithProgress = async (url: string, onProgress?: onProgress, signal?: AbortSignal): Promise<ArrayBuffer> => {
|
||||||
const response = await fetch(url, { signal });
|
const response = await fetch(url, { signal });
|
||||||
const contentLength = response.headers.get('Content-Length');
|
const contentLength = response.headers.get('Content-Length');
|
||||||
|
const isContentEncoded = !!response.headers.get('Content-Encoding');
|
||||||
|
|
||||||
if (!contentLength) {
|
if (!contentLength || isContentEncoded) {
|
||||||
// fallback
|
// fallback to full buffer
|
||||||
return response.arrayBuffer();
|
return response.arrayBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue