1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-20 21:55:03 -04:00

Async HttpClient and list lookup

This commit is contained in:
ta264
2020-05-17 11:44:10 +01:00
committed by Qstick
parent c64c2d9f27
commit c8a2af867e
10 changed files with 145 additions and 53 deletions
@@ -1,18 +1,19 @@
using System.IO;
using System.Threading.Tasks;
namespace NzbDrone.Common.Extensions
{
public static class StreamExtensions
{
public static byte[] ToBytes(this Stream input)
public static async Task<byte[]> ToBytes(this Stream input)
{
var buffer = new byte[16 * 1024];
using (var ms = new MemoryStream())
{
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
while ((read = await input.ReadAsync(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, read);
await ms.WriteAsync(buffer, 0, read);
}
return ms.ToArray();