|
@@ -123,6 +123,11 @@ internal sealed class MultipartReaderStream : Stream
|
|
|
throw new NotSupportedException();
|
|
throw new NotSupportedException();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default)
|
|
|
|
|
+ {
|
|
|
|
|
+ throw new NotSupportedException();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
|
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
|
|
{
|
|
{
|
|
|
throw new NotSupportedException();
|
|
throw new NotSupportedException();
|
|
@@ -207,7 +212,10 @@ internal sealed class MultipartReaderStream : Stream
|
|
|
return UpdatePosition(read);
|
|
return UpdatePosition(read);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
|
|
|
|
|
|
+ public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
|
|
|
|
+ => ReadAsync(buffer.AsMemory(offset, count), cancellationToken).AsTask();
|
|
|
|
|
+
|
|
|
|
|
+ public override async ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken)
|
|
|
{
|
|
{
|
|
|
if (_finished)
|
|
if (_finished)
|
|
|
{
|
|
{
|
|
@@ -231,7 +239,9 @@ internal sealed class MultipartReaderStream : Stream
|
|
|
if (matchOffset > bufferedData.Offset)
|
|
if (matchOffset > bufferedData.Offset)
|
|
|
{
|
|
{
|
|
|
// Sync, it's already buffered
|
|
// Sync, it's already buffered
|
|
|
- read = _innerStream.Read(buffer, offset, Math.Min(count, matchOffset - bufferedData.Offset));
|
|
|
|
|
|
|
+ var slice = buffer[..Math.Min(buffer.Length, matchOffset - bufferedData.Offset)];
|
|
|
|
|
+
|
|
|
|
|
+ read = _innerStream.Read(slice.Span);
|
|
|
return UpdatePosition(read);
|
|
return UpdatePosition(read);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -259,7 +269,7 @@ internal sealed class MultipartReaderStream : Stream
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// No possible boundary match within the buffered data, return the data from the buffer.
|
|
// No possible boundary match within the buffered data, return the data from the buffer.
|
|
|
- read = _innerStream.Read(buffer, offset, Math.Min(count, bufferedData.Count));
|
|
|
|
|
|
|
+ read = _innerStream.Read(buffer.Span[..Math.Min(buffer.Length, bufferedData.Count)]);
|
|
|
return UpdatePosition(read);
|
|
return UpdatePosition(read);
|
|
|
}
|
|
}
|
|
|
|
|
|