Return FINISH_REQUEST on request failure (#469)
This commit is contained in:
parent
bcc10d3012
commit
a42c8a33b8
|
|
@ -805,7 +805,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
||||||
return _readWebSocketsOperation;
|
return _readWebSocketsOperation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Task ProcessRequestAsync();
|
public abstract Task<bool> ProcessRequestAsync();
|
||||||
|
|
||||||
public void OnStarting(Func<object, Task> callback, object state)
|
public void OnStarting(Func<object, Task> callback, object state)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
||||||
_application = application;
|
_application = application;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task ProcessRequestAsync()
|
public override async Task<bool> ProcessRequestAsync()
|
||||||
{
|
{
|
||||||
var context = default(TContext);
|
var context = default(TContext);
|
||||||
|
var success = true;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -37,6 +38,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ReportApplicationError(ex);
|
ReportApplicationError(ex);
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
@ -61,6 +63,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
||||||
// If the request was aborted and no response was sent, there's no
|
// If the request was aborted and no response was sent, there's no
|
||||||
// meaningful status code to log.
|
// meaningful status code to log.
|
||||||
StatusCode = 0;
|
StatusCode = 0;
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -71,6 +74,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
||||||
{
|
{
|
||||||
// TODO Log this
|
// TODO Log this
|
||||||
_applicationException = _applicationException ?? ex;
|
_applicationException = _applicationException ?? ex;
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
@ -90,6 +94,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
||||||
await _readingTask;
|
await _readingTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
||||||
if (task.IsCompleted)
|
if (task.IsCompleted)
|
||||||
{
|
{
|
||||||
context.Dispose();
|
context.Dispose();
|
||||||
return NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_CONTINUE;
|
return ConvertRequestCompletionResults(task.Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
task.ContinueWith((t, state) => CompleteRequest((IISHttpContext)state), context);
|
task.ContinueWith((t, state) => CompleteRequest((IISHttpContext)state, t), context);
|
||||||
|
|
||||||
return NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_PENDING;
|
return NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_PENDING;
|
||||||
}
|
}
|
||||||
|
|
@ -96,15 +96,21 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
|
||||||
return NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_PENDING;
|
return NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_PENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CompleteRequest(IISHttpContext context)
|
private static void CompleteRequest(IISHttpContext context, Task<bool> completedTask)
|
||||||
{
|
{
|
||||||
// Post completion after completing the request to resume the state machine
|
// Post completion after completing the request to resume the state machine
|
||||||
context.PostCompletion(NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_CONTINUE);
|
context.PostCompletion(ConvertRequestCompletionResults(completedTask.Result));
|
||||||
|
|
||||||
// Dispose the context
|
// Dispose the context
|
||||||
context.Dispose();
|
context.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static NativeMethods.REQUEST_NOTIFICATION_STATUS ConvertRequestCompletionResults(bool success)
|
||||||
|
{
|
||||||
|
return success ? NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_CONTINUE
|
||||||
|
: NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_FINISH_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
private class IISContextFactory<T> : IISContextFactory
|
private class IISContextFactory<T> : IISContextFactory
|
||||||
{
|
{
|
||||||
private readonly IHttpApplication<T> _application;
|
private readonly IHttpApplication<T> _application;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue