diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-03-24 22:41:27 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-03-24 22:41:27 -0400 |
| commit | 8b32e3292a8ce0e0b59cfd807e4c922375cb0ed0 (patch) | |
| tree | a056a15ed19273cf0aa9770d1a5b3eae76d160ba /MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs | |
| parent | 2bdd9cc1f2aee5863134f65ee0b8cf98f44cc582 (diff) | |
fixed dashboard caching option
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs | 41 |
1 files changed, 37 insertions, 4 deletions
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 /// <returns>System.Object.</returns> public object GetResult(object content, string contentType, IDictionary<string, string> responseHeaders = null) { - var result = new HttpResult(content, contentType); + return GetHttpResult(content, contentType, responseHeaders); + } + + /// <summary> + /// Gets the HTTP result. + /// </summary> + /// <param name="content">The content.</param> + /// <param name="contentType">Type of the content.</param> + /// <param name="responseHeaders">The response headers.</param> + /// <returns>IHasOptions.</returns> + private IHasOptions GetHttpResult(object content, string contentType, IDictionary<string, string> 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; |
