mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
30 lines
758 B
C#
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);
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|