Skip to content

RunServer : buffer to small #3

@Lavoillotte

Description

@Lavoillotte

Hi

I found a bug in your SimpleWebSocketServer.
Class WebSocketHttpServer, function RunServer
buffer is to small when headers contains cookies

I propose this version for reading headers :
`...
byte[] temp = new byte[maxRead];
byte[] buffer= new byte[maxRead];
int bytesRead;
int totalBytes = 0;
while ((bytesRead=await stream.ReadAsync(temp, 0, maxRead))>0)
{
System.Array.Copy(temp, 0, buffer, totalBytes, bytesRead);
totalBytes += bytesRead;
if (stream.DataAvailable)
System.Array.Resize(ref buffer, totalBytes+bytesRead);
else
break;
}

string received = Encoding.UTF8.GetString(buffer, 0, totalBytes);
....`

regards
Nicolas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions