summaryrefslogtreecommitdiff
path: root/cli/tests/unit/fetch_test.ts
diff options
context:
space:
mode:
authorMarcos Casagrande <marcoscvp90@gmail.com>2020-07-08 04:25:34 +0200
committerGitHub <noreply@github.com>2020-07-07 22:25:34 -0400
commite4899b6ba417a801ce3d9128c9769e855487682f (patch)
treee610fc41996679ed9e863cddee028a0a22c36fa8 /cli/tests/unit/fetch_test.ts
parentcb98a594522e44fca885ca94ffdcc181ad902603 (diff)
perf(cli/body): improve .arrayBuffer() speed (#6669)
Diffstat (limited to 'cli/tests/unit/fetch_test.ts')
-rw-r--r--cli/tests/unit/fetch_test.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts
index f8ceebf6e..84f2c2822 100644
--- a/cli/tests/unit/fetch_test.ts
+++ b/cli/tests/unit/fetch_test.ts
@@ -851,6 +851,25 @@ unitTest(
}
);
+unitTest(
+ { perms: { net: true } },
+ async function fetchResponseContentLength(): Promise<void> {
+ const body = new Uint8Array(2 ** 16);
+ const headers = new Headers([["content-type", "application/octet-stream"]]);
+ const res = await fetch("http://localhost:4545/echo_server", {
+ body: body,
+ method: "POST",
+ headers,
+ });
+ assertEquals(Number(res.headers.get("content-length")), body.byteLength);
+
+ const blob = await res.blob();
+ // Make sure Body content-type is correctly set
+ assertEquals(blob.type, "application/octet-stream");
+ assertEquals(blob.size, body.byteLength);
+ }
+);
+
unitTest(function fetchResponseConstructorNullBody(): void {
const nullBodyStatus = [204, 205, 304];