From 55e54fc88cea5dbdd237b978359551da2e9713bd Mon Sep 17 00:00:00 2001 From: Step7750 Date: Fri, 20 Mar 2026 15:59:56 -0600 Subject: [PATCH] Fallback to Blob Response Body Size if No `Content-Length` Sometimes `Content-Length` isn't returned, so we want to fallback. --- src/offscreen/handlers/notary_prove.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/offscreen/handlers/notary_prove.ts b/src/offscreen/handlers/notary_prove.ts index cab74ffd..6bb637b1 100644 --- a/src/offscreen/handlers/notary_prove.ts +++ b/src/offscreen/handlers/notary_prove.ts @@ -196,12 +196,16 @@ async function calculateResponseSize( const contentLength = response.headers.get('content-length'); - if (!contentLength) { - throw new Error('no content length in response headers'); + let bodySize: number; + + if (contentLength) { + bodySize = parseInt(contentLength, 10); + } else { + console.debug('fallback to measuring response blob due to no content-length header'); + const blob = await response.blob(); + bodySize = blob.size; } - const bodySize = parseInt(contentLength, 10); - return headersSize + bodySize; }