HttpSysServer 269 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. commit cfd974337da492149fd7bb55688286d8b603b64b
  2. Author: Chris Ross (ASP.NET) <[email protected]>
  3. Date: Fri Nov 3 09:45:45 2017 -0700
  4. Improved request error handling.
  5. diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/AsyncAcceptContext.cs b/src/Microsoft.AspNetCore.Server.HttpSys/AsyncAcceptContext.cs
  6. index 01e74c19904..4c0cd867563 100644
  7. --- a/src/Microsoft.AspNetCore.Server.HttpSys/AsyncAcceptContext.cs
  8. +++ b/src/Microsoft.AspNetCore.Server.HttpSys/AsyncAcceptContext.cs
  9. @@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis;
  10. using System.Runtime.InteropServices;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. +using Microsoft.AspNetCore.Http;
  14. using Microsoft.AspNetCore.HttpSys.Internal;
  15. namespace Microsoft.AspNetCore.Server.HttpSys
  16. @@ -80,6 +81,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys
  17. complete = true;
  18. }
  19. }
  20. + catch (Exception)
  21. + {
  22. + server.SendError(asyncResult._nativeRequestContext.RequestId, StatusCodes.Status400BadRequest);
  23. + throw;
  24. + }
  25. finally
  26. {
  27. // The request has been handed to the user, which means this code can't reuse the blob. Reset it here.
  28. diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysListener.cs b/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysListener.cs
  29. index 2c70016e3f2..a1ad7493d8b 100644
  30. --- a/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysListener.cs
  31. +++ b/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysListener.cs
  32. @@ -316,7 +316,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
  33. return true;
  34. }
  35. - private unsafe void SendError(ulong requestId, int httpStatusCode, IList<string> authChallenges)
  36. + internal unsafe void SendError(ulong requestId, int httpStatusCode, IList<string> authChallenges = null)
  37. {
  38. HttpApiTypes.HTTP_RESPONSE_V2 httpResponse = new HttpApiTypes.HTTP_RESPONSE_V2();
  39. httpResponse.Response_V1.Version = new HttpApiTypes.HTTP_VERSION();
  40. diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/MessagePump.cs b/src/Microsoft.AspNetCore.Server.HttpSys/MessagePump.cs
  41. index 2b060669363..e70c52d89cb 100644
  42. --- a/src/Microsoft.AspNetCore.Server.HttpSys/MessagePump.cs
  43. +++ b/src/Microsoft.AspNetCore.Server.HttpSys/MessagePump.cs
  44. @@ -168,7 +168,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
  45. {
  46. LogHelper.LogException(_logger, "ListenForNextRequestAsync", exception);
  47. }
  48. - return;
  49. + continue;
  50. }
  51. try
  52. {