| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- commit a42c8a33b8b9c8525ad71de004f6e877759bcaf8
- Author: Justin Kotalik <[email protected]>
- Date: Wed Nov 1 15:48:04 2017 -0700
- Return FINISH_REQUEST on request failure (#469)
- diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.cs
- index 5d3fa722d1e..7dcec90f469 100644
- --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.cs
- +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContext.cs
- @@ -805,7 +805,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
- return _readWebSocketsOperation;
- }
-
- - public abstract Task ProcessRequestAsync();
- + public abstract Task<bool> ProcessRequestAsync();
-
- public void OnStarting(Func<object, Task> callback, object state)
- {
- diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContextOfT.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContextOfT.cs
- index 9f08ff7a54e..4fbd3b59563 100644
- --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContextOfT.cs
- +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpContextOfT.cs
- @@ -19,9 +19,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
- _application = application;
- }
-
- - public override async Task ProcessRequestAsync()
- + public override async Task<bool> ProcessRequestAsync()
- {
- var context = default(TContext);
- + var success = true;
-
- try
- {
- @@ -37,6 +38,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
- catch (Exception ex)
- {
- ReportApplicationError(ex);
- + success = false;
- }
- finally
- {
- @@ -61,6 +63,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
- // If the request was aborted and no response was sent, there's no
- // meaningful status code to log.
- StatusCode = 0;
- + success = false;
- }
-
- try
- @@ -71,6 +74,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
- {
- // TODO Log this
- _applicationException = _applicationException ?? ex;
- + success = false;
- }
- finally
- {
- @@ -90,6 +94,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
- await _readingTask;
- }
- }
- + return success;
- }
- }
- }
- diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs
- index e65afdfb0a3..92602936136 100644
- --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs
- +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/IISHttpServer.cs
- @@ -74,10 +74,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
- if (task.IsCompleted)
- {
- 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;
- }
- @@ -96,15 +96,21 @@ namespace Microsoft.AspNetCore.Server.IISIntegration
- 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
- - context.PostCompletion(NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_CONTINUE);
- + context.PostCompletion(ConvertRequestCompletionResults(completedTask.Result));
-
- // Dispose the context
- 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 readonly IHttpApplication<T> _application;
|