From 3da41c86fc65ee7dcaa474fa329d27661352efca Mon Sep 17 00:00:00 2001 From: Infi Date: Tue, 27 Aug 2024 17:11:16 +0200 Subject: [PATCH] End SSE connection successfully no matter the cause --- ChatTwo/Http/SSEConnection.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChatTwo/Http/SSEConnection.cs b/ChatTwo/Http/SSEConnection.cs index 1dfd7e6..535e9a2 100644 --- a/ChatTwo/Http/SSEConnection.cs +++ b/ChatTwo/Http/SSEConnection.cs @@ -59,6 +59,10 @@ public class SSEConnection // "No Content" (204) didn't work for Firefox, so manually closing the connection on client side await ctx.Response.SendFinalChunk(new CloseEvent().Build()); + // Manually confirm that we have finished our connection, even if the final response failed + // This can happen if the client disconnects before the server does + ctx.Response.ResponseSent = true; + Done = true; } }