From d8a90544d70e09d982ebcd1a8fc3e38e1b170459 Mon Sep 17 00:00:00 2001 From: Piotr Rogowski Date: Tue, 6 Apr 2021 23:43:21 +0200 Subject: [PATCH] Check for encoded content --- src/utils/http.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/http.ts b/src/utils/http.ts index e57667f..8d0fd76 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -3,9 +3,10 @@ export type onProgress = (percent: number, total: number) => void; export const fetchWithProgress = async (url: string, onProgress?: onProgress, signal?: AbortSignal): Promise => { const response = await fetch(url, { signal }); const contentLength = response.headers.get('Content-Length'); + const isContentEncoded = !!response.headers.get('Content-Encoding'); - if (!contentLength) { - // fallback + if (!contentLength || isContentEncoded) { + // fallback to full buffer return response.arrayBuffer(); }