Skip to content

Commit

Permalink
add additional security on response layer
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed Jun 28, 2024
1 parent 2a5d17a commit db0b0a1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/http/partials/Server/HTTP.ServerResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,25 @@ public ServerResponse(HttpListenerResponse response)

public void Send(int statusCode)
{
if (!IsOpened) return;
WriteAndSend(statusCode);
}

public void Write(byte[] byteBuffer)
{
if (!IsOpened) return;
_bytes.AddRange(byteBuffer);
}

public void Write(string textBuffer)
{
if (!IsOpened) return;
_bytes.AddRange(textBuffer.GetBytes(Encoding));
}

public void Send(int statusCode, string textBuffer)
{
if (!IsOpened) return;
Send(statusCode, textBuffer.GetBytes(Encoding));
}

Expand All @@ -65,6 +69,7 @@ public void Send(int statusCode, byte[] byteBuffer)

public void Redirect(string url)
{
if (!IsOpened) return;
const int redirectCode = 307; // Temporary Redirect
Redirect(redirectCode, url);
}
Expand Down

0 comments on commit db0b0a1

Please sign in to comment.