From 5eaa1e22b5198e67692dda9ecaf2c8c1be34b474 Mon Sep 17 00:00:00 2001 From: edram Date: Thu, 25 Apr 2024 16:45:25 +0800 Subject: [PATCH] Fix unsupported BodyInit type (#581) --- source/core/constants.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/source/core/constants.ts b/source/core/constants.ts index 27309629..d854ce5d 100644 --- a/source/core/constants.ts +++ b/source/core/constants.ts @@ -9,15 +9,19 @@ export const supportsRequestStreams = (() => { const supportsRequest = typeof globalThis.Request === 'function'; if (supportsReadableStream && supportsRequest) { - hasContentType = new globalThis.Request('https://empty.invalid', { - body: new globalThis.ReadableStream(), - method: 'POST', - // @ts-expect-error - Types are outdated. - get duplex() { - duplexAccessed = true; - return 'half'; - }, - }).headers.has('Content-Type'); + try { + hasContentType = new globalThis.Request('https://empty.invalid', { + body: new globalThis.ReadableStream(), + method: 'POST', + // @ts-expect-error - Types are outdated. + get duplex() { + duplexAccessed = true; + return 'half'; + }, + }).headers.has('Content-Type'); + } catch { + // IOS QQBrowser throw "unsupported BodyInit type" Error + } } return duplexAccessed && !hasContentType;