From 2937f02f00b427bffe1509a40459e02aa62e47b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 13 Aug 2021 12:07:05 +0200 Subject: fix(ext/http): remove unwrap() when HTTP conn errors (#11674) --- cli/tests/unit/http_test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'cli/tests/unit/http_test.ts') diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts index d762a6497..5262c5919 100644 --- a/cli/tests/unit/http_test.ts +++ b/cli/tests/unit/http_test.ts @@ -731,3 +731,23 @@ unitTest({ perms: { net: true } }, async function httpCookieConcatenation() { assertEquals(text, "ok"); await promise; }); + +// https://github.com/denoland/deno/issues/11651 +unitTest({ perms: { net: true } }, async function httpServerPanic() { + const listener = Deno.listen({ port: 4501 }); + const client = await Deno.connect({ port: 4501 }); + const conn = await listener.accept(); + const httpConn = Deno.serveHttp(conn); + + // This message is incomplete on purpose, we'll forcefully close client connection + // after it's flushed to cause connection to error out on the server side. + const encoder = new TextEncoder(); + await client.write(encoder.encode("GET / HTTP/1.1")); + + httpConn.nextRequest(); + await client.write(encoder.encode("\r\n\r\n")); + httpConn.close(); + + client.close(); + listener.close(); +}); -- cgit v1.2.3