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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user