diff options
author | Luca Casonato <hello@lcas.dev> | 2021-11-10 16:48:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-10 16:48:46 +0100 |
commit | 6af916c3f4842451eb7560c20f696e0f8c77da8a (patch) | |
tree | c3b0d07af68d6b59af57de0706f905608656d4db /cli/tests | |
parent | 0cb81951aff530b28b5ded8bd57cf34922b93ac6 (diff) |
fix: non ascii buffer response in http server (#12728)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/http_test.ts | 28 |
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; + }, +); |