diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs | 43 |
1 files changed, 9 insertions, 34 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index 9997cfbdb..e13e27d5a 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -102,14 +102,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer return result; } - private bool SupportsCompression - { - get - { - return true; - } - } - /// <summary> /// Gets the optimized result. /// </summary> @@ -127,7 +119,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer throw new ArgumentNullException("result"); } - var optimizedResult = SupportsCompression ? requestContext.ToOptimizedResult(result) : result; + var optimizedResult = requestContext.ToOptimizedResult(result); if (responseHeaders != null) { @@ -471,7 +463,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer { Throttle = options.Throttle, ThrottleLimit = options.ThrottleLimit, - MinThrottlePosition = options.MinThrottlePosition + MinThrottlePosition = options.MinThrottlePosition, + ThrottleCallback = options.ThrottleCallback, + OnComplete = options.OnComplete }; } @@ -488,39 +482,20 @@ namespace MediaBrowser.Server.Implementations.HttpServer { Throttle = options.Throttle, ThrottleLimit = options.ThrottleLimit, - MinThrottlePosition = options.MinThrottlePosition + MinThrottlePosition = options.MinThrottlePosition, + ThrottleCallback = options.ThrottleCallback, + OnComplete = options.OnComplete }; } string content; - long originalContentLength = 0; using (var stream = await factoryFn().ConfigureAwait(false)) { - using (var memoryStream = new MemoryStream()) - { - await stream.CopyToAsync(memoryStream).ConfigureAwait(false); - memoryStream.Position = 0; - - originalContentLength = memoryStream.Length; - - using (var reader = new StreamReader(memoryStream)) - { - content = await reader.ReadToEndAsync().ConfigureAwait(false); - } - } - } - - if (!SupportsCompression) - { - responseHeaders["Content-Length"] = originalContentLength.ToString(UsCulture); - - if (isHeadRequest) + using (var reader = new StreamReader(stream)) { - return GetHttpResult(new byte[] { }, contentType); + content = await reader.ReadToEndAsync().ConfigureAwait(false); } - - return new HttpResult(content, contentType); } var contents = content.Compress(requestedCompressionType); |
