From c6d3cfa33705278a5fea5315730833f6fcfd5536 Mon Sep 17 00:00:00 2001 From: Ivan Shynkarenka Date: Mon, 20 Nov 2023 01:05:53 +0400 Subject: [PATCH] Fix of WebSocket close status frame --- source/NetCoreServer/WebSocket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/NetCoreServer/WebSocket.cs b/source/NetCoreServer/WebSocket.cs index fb9f6a2..b9a7b5b 100644 --- a/source/NetCoreServer/WebSocket.cs +++ b/source/NetCoreServer/WebSocket.cs @@ -257,8 +257,8 @@ public bool PerformServerUpgrade(HttpRequest request, HttpResponse response) /// WebSocket status (default is 0) public void PrepareSendFrame(byte opcode, bool mask, ReadOnlySpan buffer, int status = 0) { - bool storeWSCloseStatus = (opcode & WS_CLOSE) == WS_CLOSE; - long size = storeWSCloseStatus ? (buffer.Length + 2) : buffer.Length; + bool storeStatus = (opcode & WS_CLOSE) == WS_CLOSE; + long size = storeStatus ? (buffer.Length + 2) : buffer.Length; // Clear the previous WebSocket send buffer WsSendBuffer.Clear(); @@ -298,7 +298,7 @@ public void PrepareSendFrame(byte opcode, bool mask, ReadOnlySpan buffer, // RFC 6455: If there is a body, the first two bytes of the body MUST // be a 2-byte unsigned integer (in network byte order) representing // a status code with value code. - if (storeWSCloseStatus) + if (storeStatus) { index += 2; WsSendBuffer.Data[offset + 0] = (byte)(((status >> 8) & 0xFF) ^ WsSendMask[0]);