Skip to content

Commit

Permalink
fix(blob): ignore Content-Length mismatch if Content-Encoding set (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
incognitojam authored Jan 18, 2025
1 parent 07437e6 commit a32b8fd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export async function download(url) {
const response = await fetch(url, { mode: 'cors' })
const reader = response.body.getReader()
const contentLength = +response.headers.get('Content-Length')
const contentEncoding = response.headers.get('Content-Encoding')
console.debug('[blob] Downloading', url, contentLength)

const chunks = []
Expand All @@ -13,7 +14,7 @@ export async function download(url) {

const blob = new Blob(chunks)
console.debug('[blob] Downloaded', url, blob.size)
if (blob.size !== contentLength) console.warn('[blob] Download size mismatch', {
if (!contentEncoding && blob.size !== contentLength) console.warn('[blob] Download size mismatch', {
url,
expected: contentLength,
actual: blob.size,
Expand Down

0 comments on commit a32b8fd

Please sign in to comment.