Closed
Description
Describe the bug
New Write/WriteLine/WriteAsync/WriteLineAsync ReadOnlySpan/ReadOnlyMemory overloads
in HttpResponseStreamWriter.cs will not write all data if the data exceeds internal buffer.
See code from pull request (#18451) with my comments:
public override void Write(ReadOnlySpan<char> value)
{
if (_disposed)
{
throw new ObjectDisposedException(nameof(HttpResponseStreamWriter));
}
var written = 0;
while (written < value.Length)
{
if (_charBufferCount == _charBufferSize)
{
FlushInternal(flushEncoder: false);
}
written = CopyToCharBuffer(value);
if (written < value.Length)
{
value = value.Slice(written);
// if "written" >= value.Length
// then we will exit loop and last chunk will not be copied
// to fix this we should reset "written" after each Slice
}
};
}
The same problem exists in WriteAsyncAwaited(ReadOnlyMemory value)
To Reproduce
Further technical details
- ASP.NET Core version