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