another improvement

This commit is contained in:
2025-02-06 15:00:46 +01:00
parent 295644087f
commit ab67023ea4

View File

@@ -280,31 +280,27 @@ public class ApiServer : IApiServer
if (AllowMultipleRequests)
Receive();
// Cancel if we don't have a context
if (context is null)
{
FreeSlot();
return;
}
// Check context
Log.Info("Request retrived for " + context.Request.RawUrl);
OnCheckContext?.Invoke(this, new(context));
var success = false;
try
if (context is not null)
{
CheckContext(context);
success = true;
}
catch (Exception ex)
{
Log.Error("Error checking context", ex);
if (DebugMode)
throw;
}
finally
{
OnCheckContextCompleted?.Invoke(this, new(context));
Log.Info("Request retrived for " + context.Request.RawUrl);
OnCheckContext?.Invoke(this, new(context));
try
{
CheckContext(context);
success = true;
}
catch (Exception ex)
{
Log.Error("Error checking context", ex);
if (DebugMode)
throw;
}
finally
{
OnCheckContextCompleted?.Invoke(this, new(context));
}
}
// Try closing the request on fail
@@ -312,7 +308,7 @@ public class ApiServer : IApiServer
{
try
{
context.Response.Close();
context?.Response.Close();
}
catch (Exception)
{