From fe9cee620a4c0d8923bdf99882f95275b69abcb4 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 15 Apr 2021 18:48:56 -0400 Subject: fix(#10182): hang during http server response (#10197) --- cli/tests/unit/http_test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'cli/tests/unit') diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts index f7ea3a75a..6383afd42 100644 --- a/cli/tests/unit/http_test.ts +++ b/cli/tests/unit/http_test.ts @@ -200,3 +200,30 @@ unitTest( client.close(); }, ); + +unitTest( + { perms: { net: true } }, + async function httpServerRegressionHang() { + const promise = (async () => { + const listener = Deno.listen({ port: 4501 }); + const conn = await listener.accept(); + const httpConn = Deno.serveHttp(conn); + const event = await httpConn.nextRequest(); + assert(event); + const { request, respondWith } = event; + const reqBody = await request.text(); + assertEquals("request", reqBody); + await respondWith(new Response("response")); + httpConn.close(); + listener.close(); + })(); + + const resp = await fetch("http://127.0.0.1:4501/", { + method: "POST", + body: "request", + }); + const respBody = await resp.text(); + assertEquals("response", respBody); + await promise; + }, +); -- cgit v1.2.3