Suppress log when request is cancelled (#16691)

This commit is contained in:
Kahbazi 2019-11-21 03:21:01 +03:30 committed by Chris Ross
parent 242890940e
commit 642fe1631d
1 changed files with 6 additions and 3 deletions

View File

@ -127,9 +127,12 @@ namespace Microsoft.AspNetCore.Server.HttpSys
var flags = ComputeLeftToWrite(data.Count, endOfRequest); var flags = ComputeLeftToWrite(data.Count, endOfRequest);
if (endOfRequest && _leftToWrite > 0) if (endOfRequest && _leftToWrite > 0)
{ {
if (!RequestContext.DisconnectToken.IsCancellationRequested)
{
// This is logged rather than thrown because it is too late for an exception to be visible in user code.
LogHelper.LogError(Logger, "ResponseStream::Dispose", "Fewer bytes were written than were specified in the Content-Length.");
}
_requestContext.Abort(); _requestContext.Abort();
// This is logged rather than thrown because it is too late for an exception to be visible in user code.
LogHelper.LogError(Logger, "ResponseStream::Dispose", "Fewer bytes were written than were specified in the Content-Length.");
return; return;
} }
@ -690,8 +693,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys
{ {
return; return;
} }
_disposed = true;
FlushInternal(endOfRequest: true); FlushInternal(endOfRequest: true);
_disposed = true;
} }
} }
finally finally