Skip to content

Commit

Permalink
Fix of WebSocket close status frame
Browse files Browse the repository at this point in the history
  • Loading branch information
chronoxor committed Nov 19, 2023
1 parent a9de497 commit c6d3cfa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions source/NetCoreServer/WebSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ public bool PerformServerUpgrade(HttpRequest request, HttpResponse response)
/// <param name="status">WebSocket status (default is 0)</param>
public void PrepareSendFrame(byte opcode, bool mask, ReadOnlySpan<byte> 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();
Expand Down Expand Up @@ -298,7 +298,7 @@ public void PrepareSendFrame(byte opcode, bool mask, ReadOnlySpan<byte> 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]);
Expand Down

0 comments on commit c6d3cfa

Please sign in to comment.