Skip to content

Commit

Permalink
try fix "Source array was not long enough. Exception" *3
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed Dec 21, 2024
1 parent ba8cb0c commit bb0a9b7
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/http/partials/Server/HTTP.ServerResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,10 @@ public void Send(int statusCode, string textBuffer)

if (!string.IsNullOrEmpty(textBuffer))
{
byte[] buffer = null;
var buffer = textBuffer.GetBytes(Encoding);

try
{
buffer = textBuffer.GetBytes(Encoding);
}
finally
{
if (buffer != null && buffer.Length > 0)
{
if (buffer.Length == 1) _bytes.Add(buffer[0]);
else _bytes.AddRange(buffer);
}
}
if (buffer != null && buffer.Length > 0)
_bytes.AddRange(buffer);
}

WriteAndSend(statusCode);
Expand Down

0 comments on commit bb0a9b7

Please sign in to comment.