From cd0a9a395f98ad8622637d34152fb071e5f8b2ad Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Mon, 1 Jan 2024 01:25:25 +0800 Subject: [PATCH] fix null body webdav --- src/remoteForWebdav.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/remoteForWebdav.ts b/src/remoteForWebdav.ts index 53d2997..b8cd0d1 100644 --- a/src/remoteForWebdav.ts +++ b/src/remoteForWebdav.ts @@ -97,11 +97,23 @@ if (VALID_REQURL) { // ); // } - const r2 = new Response(r.arrayBuffer, { - status: r.status, - statusText: getReasonPhrase(r.status), - headers: r.headers, - }); + let r2: Response = undefined; + if ([101, 103, 204, 205, 304].includes(r.status)) { + // A null body status is a status that is 101, 103, 204, 205, or 304. + // fix this: Failed to construct 'Response': Response with null body status cannot have body + r2 = new Response(null, { + status: r.status, + statusText: getReasonPhrase(r.status), + headers: r.headers, + }); + } else { + r2 = new Response(r.arrayBuffer, { + status: r.status, + statusText: getReasonPhrase(r.status), + headers: r.headers, + }); + } + return r2; } );