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