From 15b1aaf83b4bc7ecd15e80a01328c6a575c43b49 Mon Sep 17 00:00:00 2001 From: uwaa Date: Mon, 2 Dec 2024 16:20:04 +0000 Subject: [PATCH] http: improve socket closure, keepalive --- HTTP/HttpServer.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/HTTP/HttpServer.cs b/HTTP/HttpServer.cs index 5f2746c..6cfb29c 100644 --- a/HTTP/HttpServer.cs +++ b/HTTP/HttpServer.cs @@ -168,14 +168,12 @@ public sealed class HttpServer //Create and run websocket WebsocketRemote ws = new WebsocketRemote(req, clientInfo, httpStream, swp.Fields.WebSocketProtocol); CloseStatus closeStatus = await swp.Callback(ws); - ws.Close(closeStatus); + await ws.Close(closeStatus).WaitAsync(Timeout); break; //Close } - else - { - if (response.StatusCode is not >= 200 or not < 300 || (req.Fields.Connection == ConnectionType.Close)) - break; //Close - } + + if (req.Fields.Connection == ConnectionType.Close) + break; //Close } catch (HttpException e) {