Skip to content

Commit

Permalink
HttpServer, always debug connection info
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed Nov 15, 2023
1 parent aae6aa0 commit 6a28b2a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/HTTP/HttpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,38 @@ private void _ReceiveRequests()
var request = new Request(context.Request);
var response = new Response(context.Response);

// TODO: Only show on debug mode
{
string headerDebug = "\n\tHeaders:";
foreach (var header in request.Headers.AllKeyValue)
{
headerDebug += $"\n\t{header.Key}:{header.Value}";
}

string cookiesDebug = "\n\tCookies:";
foreach (var cookie in request.Cookies)
{
cookiesDebug += $"\n\t{cookie.Name}:{cookie.Value} [{cookie.Port}:{cookie.Path}]";
}

string queriesDebug = "\n\t:Queries:";
foreach (var query in request.Queries.AllKeyValue)
{
queriesDebug += $"\n\t{query.Key}:{query.Value}";
}

Console.WriteLine
(
"Receive connection" +
$"\n\tUrl: {request.RawRequest.Url.AbsoluteUri}" +
$"\n\tPath: {request.RawRequest.Url.AbsolutePath}" +
$"\n\tLocal Path: {request.RawRequest.Url.LocalPath}" +
$"\n\tIs Websocket: {context.Request.IsWebSocketRequest}" +
$"\n\n{headerDebug}" +
$"\n\n{queriesDebug}" +
$"\n\n{cookiesDebug}"
);
}

if (context.Request.IsWebSocketRequest is false)
{
Expand Down

0 comments on commit 6a28b2a

Please sign in to comment.