Empty buffer when null buffer

This commit is contained in:
Ben Adams 2015-12-01 04:36:23 +00:00
parent 32a038e5ea
commit a55be21469
1 changed files with 4 additions and 2 deletions

View File

@ -12,6 +12,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Filter
{
public class StreamSocketOutput : ISocketOutput
{
private static readonly byte[] _nullBuffer = new byte[0];
private readonly Stream _outputStream;
private readonly MemoryPool2 _memory;
private MemoryPoolBlock2 _producingBlock;
@ -24,13 +26,13 @@ namespace Microsoft.AspNet.Server.Kestrel.Filter
void ISocketOutput.Write(ArraySegment<byte> buffer, bool immediate)
{
_outputStream.Write(buffer.Array, buffer.Offset, buffer.Count);
_outputStream.Write(buffer.Array ?? _nullBuffer, buffer.Offset, buffer.Count);
}
Task ISocketOutput.WriteAsync(ArraySegment<byte> buffer, bool immediate, CancellationToken cancellationToken)
{
// TODO: Use _outputStream.WriteAsync
_outputStream.Write(buffer.Array, buffer.Offset, buffer.Count);
_outputStream.Write(buffer.Array ?? _nullBuffer, buffer.Offset, buffer.Count);
return TaskUtilities.CompletedTask;
}