Skip to content

Commit 642fe16

Browse files
KahbaziTratcher
authored andcommitted
Suppress log when request is cancelled (#16691)
1 parent 2428909 commit 642fe16

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Servers/HttpSys/src/RequestProcessing/ResponseBody.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,12 @@ public override void Flush()
127127
var flags = ComputeLeftToWrite(data.Count, endOfRequest);
128128
if (endOfRequest && _leftToWrite > 0)
129129
{
130+
if (!RequestContext.DisconnectToken.IsCancellationRequested)
131+
{
132+
// This is logged rather than thrown because it is too late for an exception to be visible in user code.
133+
LogHelper.LogError(Logger, "ResponseStream::Dispose", "Fewer bytes were written than were specified in the Content-Length.");
134+
}
130135
_requestContext.Abort();
131-
// This is logged rather than thrown because it is too late for an exception to be visible in user code.
132-
LogHelper.LogError(Logger, "ResponseStream::Dispose", "Fewer bytes were written than were specified in the Content-Length.");
133136
return;
134137
}
135138

@@ -690,8 +693,8 @@ protected override unsafe void Dispose(bool disposing)
690693
{
691694
return;
692695
}
693-
_disposed = true;
694696
FlushInternal(endOfRequest: true);
697+
_disposed = true;
695698
}
696699
}
697700
finally

0 commit comments

Comments
 (0)