in CachingProxy/src/CachingProxy.cs [438:451]
private static async Task CopyToTwoStreamsAsync(Stream source, Stream dest1, FileStream dest2, CancellationToken cancellationToken)
{
using var buffer = MemoryPool<byte>.Shared.Rent(BUFFER_SIZE);
var memory = buffer.Memory;
while (true)
{
var length = await source.ReadAsync(memory, cancellationToken).ConfigureAwait(false);
if (length == 0)
break;
await dest1.WriteAsync(memory[..length], cancellationToken).ConfigureAwait(false);
await dest2.WriteAsync(memory[..length], cancellationToken).ConfigureAwait(false);
}
}