From 744aaaa48d5b9aed856ef550ecc23a8750e9a4a0 Mon Sep 17 00:00:00 2001 From: Harald Wolff-Thobaben Date: Mon, 7 Mar 2022 11:58:54 +0100 Subject: [PATCH] Handle IOException(SocketException) in HttpServer.HandleConnection(..) --- ln.http/HTTPServer.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ln.http/HTTPServer.cs b/ln.http/HTTPServer.cs index 24212e1..873a40c 100644 --- a/ln.http/HTTPServer.cs +++ b/ln.http/HTTPServer.cs @@ -151,8 +151,15 @@ namespace ln.http .Content(String.Format("An internal error occured ({0})", exception.ToString())); } - httpContext.Response.WriteTo(connection.GetStream()); - httpContext.Response?.ContentStream?.Dispose(); + try + { + httpContext.Response.WriteTo(connection.GetStream()); + httpContext.Response?.ContentStream?.Dispose(); + } + catch (IOException ioexception) + { + break; + } keepalive = httpContext.Response.GetHeader("connection", "keep-alive").Equals("keep-alive") && httpRequest .GetRequestHeader("connection",