Add Memory<byte> overloads to HttpUpgradeStream (#2622)

This commit is contained in:
Stephen Halter 2018-05-31 15:44:39 -07:00 committed by GitHub
parent 5ec7bacdfe
commit af177c5adc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -145,6 +145,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
return _requestStream.ReadAsync(buffer, offset, count, cancellationToken);
}
#if NETCOREAPP2_1
public override ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default)
{
return _requestStream.ReadAsync(destination, cancellationToken);
}
#endif
public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
{
return _requestStream.CopyToAsync(destination, bufferSize, cancellationToken);
@ -155,6 +162,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
return _responseStream.WriteAsync(buffer, offset, count, cancellationToken);
}
#if NETCOREAPP2_1
public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default)
{
return _responseStream.WriteAsync(source, cancellationToken);
}
#endif
public override long Seek(long offset, SeekOrigin origin)
{
return _requestStream.Seek(offset, origin);

View File

@ -68,6 +68,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
=> _inner.ReadAsync(buffer, offset, count, cancellationToken);
#if NETCOREAPP2_1
public override ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default)
=> _inner.ReadAsync(destination, cancellationToken);
#endif
public override int ReadByte()
=> _inner.ReadByte();
@ -83,6 +88,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
=> _inner.WriteAsync(buffer, offset, count, cancellationToken);
#if NETCOREAPP2_1
public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default)
=> _inner.WriteAsync(source, cancellationToken);
#endif
public override void WriteByte(byte value)
=> _inner.WriteByte(value);