summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2021-11-10 16:48:46 +0100
committerGitHub <noreply@github.com>2021-11-10 16:48:46 +0100
commit6af916c3f4842451eb7560c20f696e0f8c77da8a (patch)
treec3b0d07af68d6b59af57de0706f905608656d4db /cli/tests
parent0cb81951aff530b28b5ded8bd57cf34922b93ac6 (diff)
fix: non ascii buffer response in http server (#12728)
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/unit/http_test.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts
index d947282db..a6f80eb2c 100644
--- a/cli/tests/unit/http_test.ts
+++ b/cli/tests/unit/http_test.ts
@@ -999,3 +999,31 @@ unitTest(
await Promise.all([server(), client()]);
},
);
+
+unitTest(
+ { permissions: { net: true } },
+ async function httpServerRespondNonAsciiUint8Array() {
+ const promise = (async () => {
+ const listener = Deno.listen({ port: 4501 });
+ const conn = await listener.accept();
+ listener.close();
+ const httpConn = Deno.serveHttp(conn);
+ const e = await httpConn.nextRequest();
+ assert(e);
+ const { request, respondWith } = e;
+ assertEquals(request.body, null);
+ await respondWith(
+ new Response(new Uint8Array([128]), {}),
+ );
+ httpConn.close();
+ })();
+
+ const resp = await fetch("http://localhost:4501/");
+ console.log(resp.headers);
+ assertEquals(resp.status, 200);
+ const body = await resp.arrayBuffer();
+ assertEquals(new Uint8Array(body), new Uint8Array([128]));
+
+ await promise;
+ },
+);