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.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpSys.Internal;
namespace Microsoft.AspNetCore.Server.HttpSys
@ -80,6 +81,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys
complete = true;
}
}
catch (Exception)
{
server.SendError(asyncResult._nativeRequestContext.RequestId, StatusCodes.Status400BadRequest);
throw;
}
finally
{
// 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;
}
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();
httpResponse.Response_V1.Version = new HttpApiTypes.HTTP_VERSION();

View File

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