From f354dfebe9f45ba33e6ad3b6f3163d516c9d0727 Mon Sep 17 00:00:00 2001 From: Tanguy Cizain Date: Tue, 31 Aug 2021 16:30:09 +0200 Subject: [PATCH] allow accept cancellation (#91) --- websock/http/server.nim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/websock/http/server.nim b/websock/http/server.nim index 530bbdc233..c00a3eb031 100644 --- a/websock/http/server.nim +++ b/websock/http/server.nim @@ -190,7 +190,12 @@ proc accept*(server: HttpServer): Future[HttpRequest] writer: newAsyncStreamWriter(transp)) trace "Got new request", isTls = server.secure - return await server.parseRequest(stream) + try: + return await server.parseRequest(stream) + except CatchableError as exc: + await stream.closeWait() + raise exc + proc create*( _: typedesc[HttpServer],