Improved request error handling.

This commit is contained in:
Chris Ross (ASP.NET) 2017-11-03 09:45:45 -07:00
parent 58fb4f322e
commit cfd974337d
3 changed files with 8 additions and 2 deletions

View File

@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpSys.Internal; using Microsoft.AspNetCore.HttpSys.Internal;
namespace Microsoft.AspNetCore.Server.HttpSys namespace Microsoft.AspNetCore.Server.HttpSys
@ -80,6 +81,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys
complete = true; complete = true;
} }
} }
catch (Exception)
{
server.SendError(asyncResult._nativeRequestContext.RequestId, StatusCodes.Status400BadRequest);
throw;
}
finally finally
{ {
// The request has been handed to the user, which means this code can't reuse the blob. Reset it here. // The request has been handed to the user, which means this code can't reuse the blob. Reset it here.

View File

@ -316,7 +316,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
return true; return true;
} }
private unsafe void SendError(ulong requestId, int httpStatusCode, IList<string> authChallenges) internal unsafe void SendError(ulong requestId, int httpStatusCode, IList<string> authChallenges = null)
{ {
HttpApiTypes.HTTP_RESPONSE_V2 httpResponse = new HttpApiTypes.HTTP_RESPONSE_V2(); HttpApiTypes.HTTP_RESPONSE_V2 httpResponse = new HttpApiTypes.HTTP_RESPONSE_V2();
httpResponse.Response_V1.Version = new HttpApiTypes.HTTP_VERSION(); httpResponse.Response_V1.Version = new HttpApiTypes.HTTP_VERSION();

View File

@ -168,7 +168,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
{ {
LogHelper.LogException(_logger, "ListenForNextRequestAsync", exception); LogHelper.LogException(_logger, "ListenForNextRequestAsync", exception);
} }
return; continue;
} }
try try
{ {