From e2f8d140380d516994becdf1a7fa5ccd8fd21feb Mon Sep 17 00:00:00 2001 From: Ivan Shynkarenka Date: Fri, 12 Aug 2022 22:15:25 +0400 Subject: [PATCH] Browser connections fail with "A server must not mask any frames that it sends to the client" #213 --- source/NetCoreServer/NetCoreServer.csproj | 2 +- source/NetCoreServer/WsSession.cs | 20 ++++++++++---------- source/NetCoreServer/WssSession.cs | 20 ++++++++++---------- tests/tests.csproj | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/source/NetCoreServer/NetCoreServer.csproj b/source/NetCoreServer/NetCoreServer.csproj index 832a93b..b17b36a 100644 --- a/source/NetCoreServer/NetCoreServer.csproj +++ b/source/NetCoreServer/NetCoreServer.csproj @@ -2,7 +2,7 @@ net6.0 - 6.4.0.0 + 6.5.0.0 Ivan Shynkarenka Copyright (c) 2019-2022 Ivan Shynkarenka https://github.com/chronoxor/NetCoreServer diff --git a/source/NetCoreServer/WsSession.cs b/source/NetCoreServer/WsSession.cs index 6166551..2296244 100644 --- a/source/NetCoreServer/WsSession.cs +++ b/source/NetCoreServer/WsSession.cs @@ -27,7 +27,7 @@ public long SendText(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_TEXT, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_TEXT, false, buffer); return base.Send(WebSocket.WsSendBuffer.AsSpan()); } } @@ -40,7 +40,7 @@ public bool SendTextAsync(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_TEXT, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_TEXT, false, buffer); return base.SendAsync(WebSocket.WsSendBuffer.AsSpan()); } } @@ -58,7 +58,7 @@ public long SendBinary(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_BINARY, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_BINARY, false, buffer); return base.Send(WebSocket.WsSendBuffer.AsSpan()); } } @@ -71,7 +71,7 @@ public bool SendBinaryAsync(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_BINARY, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_BINARY, false, buffer); return base.SendAsync(WebSocket.WsSendBuffer.AsSpan()); } } @@ -89,7 +89,7 @@ public long SendClose(int status, ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_CLOSE, true, buffer, status); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_CLOSE, false, buffer, status); return base.Send(WebSocket.WsSendBuffer.AsSpan()); } } @@ -102,7 +102,7 @@ public bool SendCloseAsync(int status, ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_CLOSE, true, buffer, status); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_CLOSE, false, buffer, status); return base.SendAsync(WebSocket.WsSendBuffer.AsSpan()); } } @@ -120,7 +120,7 @@ public long SendPing(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PING, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PING, false, buffer); return base.Send(WebSocket.WsSendBuffer.AsSpan()); } } @@ -133,7 +133,7 @@ public bool SendPingAsync(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PING, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PING, false, buffer); return base.SendAsync(WebSocket.WsSendBuffer.AsSpan()); } } @@ -151,7 +151,7 @@ public long SendPong(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PONG, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PONG, false, buffer); return base.Send(WebSocket.WsSendBuffer.AsSpan()); } } @@ -164,7 +164,7 @@ public bool SendPongAsync(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PONG, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PONG, false, buffer); return base.SendAsync(WebSocket.WsSendBuffer.AsSpan()); } } diff --git a/source/NetCoreServer/WssSession.cs b/source/NetCoreServer/WssSession.cs index cc612c8..c0fb4da 100644 --- a/source/NetCoreServer/WssSession.cs +++ b/source/NetCoreServer/WssSession.cs @@ -27,7 +27,7 @@ public long SendText(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_TEXT, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_TEXT, false, buffer); return base.Send(WebSocket.WsSendBuffer.AsSpan()); } } @@ -40,7 +40,7 @@ public bool SendTextAsync(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_TEXT, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_TEXT, false, buffer); return base.SendAsync(WebSocket.WsSendBuffer.AsSpan()); } } @@ -58,7 +58,7 @@ public long SendBinary(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_BINARY, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_BINARY, false, buffer); return base.Send(WebSocket.WsSendBuffer.AsSpan()); } } @@ -71,7 +71,7 @@ public bool SendBinaryAsync(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_BINARY, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_BINARY, false, buffer); return base.SendAsync(WebSocket.WsSendBuffer.AsSpan()); } } @@ -89,7 +89,7 @@ public long SendClose(int status, ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_CLOSE, true, buffer, status); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_CLOSE, false, buffer, status); return base.Send(WebSocket.WsSendBuffer.AsSpan()); } } @@ -102,7 +102,7 @@ public bool SendCloseAsync(int status, ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_CLOSE, true, buffer, status); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_CLOSE, false, buffer, status); return base.SendAsync(WebSocket.WsSendBuffer.AsSpan()); } } @@ -120,7 +120,7 @@ public long SendPing(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PING, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PING, false, buffer); return base.Send(WebSocket.WsSendBuffer.AsSpan()); } } @@ -133,7 +133,7 @@ public bool SendPingAsync(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PING, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PING, false, buffer); return base.SendAsync(WebSocket.WsSendBuffer.AsSpan()); } } @@ -151,7 +151,7 @@ public long SendPong(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PONG, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PONG, false, buffer); return base.Send(WebSocket.WsSendBuffer.AsSpan()); } } @@ -164,7 +164,7 @@ public bool SendPongAsync(ReadOnlySpan buffer) { lock (WebSocket.WsSendLock) { - WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PONG, true, buffer); + WebSocket.PrepareSendFrame(WebSocket.WS_FIN | WebSocket.WS_PONG, false, buffer); return base.SendAsync(WebSocket.WsSendBuffer.AsSpan()); } } diff --git a/tests/tests.csproj b/tests/tests.csproj index eb4faff..753102a 100644 --- a/tests/tests.csproj +++ b/tests/tests.csproj @@ -6,7 +6,7 @@ - + all