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); } }; } } }