-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
69 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Difference between cloning and copying of a `Response`: | ||
* https://community.cloudflare.com/t/whats-the-point-of-response-clone/216456 | ||
*/ | ||
export function copyResponse(response) { | ||
return new Response(response.body, response); | ||
} | ||
|
||
export function getResponseBody(input) { | ||
if (typeof input === "string") { | ||
return input; | ||
} else if (input === undefined || input === null) { | ||
return ""; | ||
} else if ( | ||
input instanceof Blob || input instanceof ArrayBuffer || | ||
ArrayBuffer.isView(input) || input instanceof DataView || | ||
input instanceof URLSearchParams || input instanceof FormData || | ||
input instanceof ReadableStream | ||
) { | ||
return input; | ||
} else { | ||
return JSON.stringify(input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters