React to OnSendingHeaders rename.
This commit is contained in:
parent
6dbbe831c4
commit
ef4ab17700
|
|
@ -28,17 +28,15 @@ namespace Microsoft.AspNet.Diagnostics
|
|||
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
var responseStarted = false;
|
||||
try
|
||||
{
|
||||
context.Response.OnSendingHeaders(state => responseStarted = true, null);
|
||||
await _next(context);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError("An unhandled exception has occurred: " + ex.Message, ex);
|
||||
// We can't do anything if the response has already started, just abort.
|
||||
if (responseStarted)
|
||||
if (context.Response.HasStarted)
|
||||
{
|
||||
_logger.LogWarning("The response has already started, the error handler will not be executed.");
|
||||
throw;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace Microsoft.AspNet.Diagnostics
|
|||
}
|
||||
|
||||
// Do nothing if a response body has already been provided.
|
||||
if (context.Response.HeadersSent
|
||||
if (context.Response.HasStarted
|
||||
|| context.Response.StatusCode < 400
|
||||
|| context.Response.StatusCode >= 600
|
||||
|| context.Response.ContentLength.HasValue
|
||||
|
|
|
|||
Loading…
Reference in New Issue