Files
Prowlarr-Prowlarr/src/Prowlarr.Http/Extensions/ResponseExtensions.cs
2021-02-17 23:47:50 -05:00

30 lines
758 B
C#

using System.IO;
using Nancy;
namespace NzbDrone.Http.Extensions
{
public static class ResponseExtensions
{
public static Response FromByteArray(this IResponseFormatter formatter, byte[] body, string contentType = null)
{
return new ByteArrayResponse(body, contentType);
}
}
public class ByteArrayResponse : Response
{
public ByteArrayResponse(byte[] body, string contentType = null)
{
this.ContentType = contentType ?? "application/octet-stream";
this.Contents = stream =>
{
using (var writer = new BinaryWriter(stream))
{
writer.Write(body);
}
};
}
}
}