Ejemplo n.º 1
0
        public Task WriteAsync(Span <byte> data)
        {
            var buffer = _output.Alloc();

            if (!HasStarted)
            {
                WriteBeginResponseHeaders(ref buffer, ref _autoChunk);
            }

            if (_autoChunk)
            {
                ChunkWriter.WriteBeginChunkBytes(ref buffer, data.Length);
                buffer.Write(data);
                ChunkWriter.WriteEndChunkBytes(ref buffer);
            }
            else
            {
                buffer.Write(data);
            }

            return(buffer.FlushAsync());
        }
Ejemplo n.º 2
0
        public Task WriteAsync(byte[] array, int offset, int count)
        {
            var buffer = _output.Alloc();

            if (!HasStarted)
            {
                WriteBeginResponseHeaders(ref buffer, ref _autoChunk);
            }

            if (_autoChunk)
            {
                ChunkWriter.WriteBeginChunkBytes(ref buffer, count);
                buffer.Write(array, offset, count);
                ChunkWriter.WriteEndChunkBytes(ref buffer);
            }
            else
            {
                buffer.Write(array, offset, count);
            }

            return(_output.WriteAsync(buffer));
        }