From 8b32e3292a8ce0e0b59cfd807e4c922375cb0ed0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 24 Mar 2013 22:41:27 -0400 Subject: fixed dashboard caching option --- .../HttpServer/HttpResultFactory.cs | 41 +++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs') diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index 78b883d34..41ef15bc9 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -43,13 +43,46 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// System.Object. public object GetResult(object content, string contentType, IDictionary responseHeaders = null) { - var result = new HttpResult(content, contentType); + return GetHttpResult(content, contentType, responseHeaders); + } + + /// + /// Gets the HTTP result. + /// + /// The content. + /// Type of the content. + /// The response headers. + /// IHasOptions. + private IHasOptions GetHttpResult(object content, string contentType, IDictionary responseHeaders = null) + { + IHasOptions result; + + var stream = content as Stream; + + if (stream != null) + { + result = new StreamWriter(stream, contentType, _logger); + } + + else + { + var bytes = content as byte[]; + + if (bytes != null) + { + result = new StreamWriter(bytes, contentType, _logger); + } + else + { + result = new HttpResult(content, contentType); + } + } if (responseHeaders != null) { AddResponseHeaders(result, responseHeaders); } - + return result; } @@ -376,7 +409,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer if (isHeadRequest) { - return new HttpResult(new byte[] { }, contentType); + return GetHttpResult(new byte[] { }, contentType); } return new StreamWriter(stream, contentType, _logger); @@ -384,7 +417,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer if (isHeadRequest) { - return new HttpResult(new byte[] { }, contentType); + return GetHttpResult(new byte[] { }, contentType); } string content; -- cgit v1.2.3