From f32212d160f5427a56b5b8e0219206930c518b64 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 7 Dec 2013 10:52:38 -0500 Subject: update to service stack v4 --- .../HttpServer/HttpResultFactory.cs | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 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 5a5a2dd04..798632af7 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -2,10 +2,8 @@ using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; using MediaBrowser.Controller.IO; +using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; -using ServiceStack.Common; -using ServiceStack.Common.Web; -using ServiceStack.ServiceHost; using System; using System.Collections.Generic; using System.Globalization; @@ -13,6 +11,8 @@ using System.IO; using System.Net; using System.Text; using System.Threading.Tasks; +using ServiceStack; +using ServiceStack.Web; using MimeTypes = MediaBrowser.Common.Net.MimeTypes; namespace MediaBrowser.Server.Implementations.HttpServer @@ -116,7 +116,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The response headers. /// System.Object. /// result - public object GetOptimizedResult(IRequestContext requestContext, T result, IDictionary responseHeaders = null) + public object GetOptimizedResult(IRequest requestContext, T result, IDictionary responseHeaders = null) where T : class { if (result == null) @@ -156,7 +156,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// or /// factoryFn /// - public object GetOptimizedResultUsingCache(IRequestContext requestContext, Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func factoryFn, IDictionary responseHeaders = null) + public object GetOptimizedResultUsingCache(IRequest requestContext, Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func factoryFn, IDictionary responseHeaders = null) where T : class { if (cacheKey == Guid.Empty) @@ -199,7 +199,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The response headers. /// System.Object. /// cacheKey - public object GetCachedResult(IRequestContext requestContext, Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func factoryFn, string contentType, IDictionary responseHeaders = null) + public object GetCachedResult(IRequest requestContext, Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func factoryFn, string contentType, IDictionary responseHeaders = null) where T : class { if (cacheKey == Guid.Empty) @@ -256,7 +256,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// Duration of the cache. /// Type of the content. /// System.Object. - private object GetCachedResult(IRequestContext requestContext, IDictionary responseHeaders, Guid cacheKey, string cacheKeyString, DateTime? lastDateModified, TimeSpan? cacheDuration, string contentType) + private object GetCachedResult(IRequest requestContext, IDictionary responseHeaders, Guid cacheKey, string cacheKeyString, DateTime? lastDateModified, TimeSpan? cacheDuration, string contentType) { responseHeaders["ETag"] = cacheKeyString; @@ -287,7 +287,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// if set to true [is head request]. /// System.Object. /// path - public object GetStaticFileResult(IRequestContext requestContext, string path, FileShare fileShare = FileShare.Read, IDictionary responseHeaders = null, bool isHeadRequest = false) + public object GetStaticFileResult(IRequest requestContext, string path, FileShare fileShare = FileShare.Read, IDictionary responseHeaders = null, bool isHeadRequest = false) { if (string.IsNullOrEmpty(path)) { @@ -332,7 +332,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// cacheKey /// or /// factoryFn - public object GetStaticResult(IRequestContext requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, string contentType, Func> factoryFn, IDictionary responseHeaders = null, bool isHeadRequest = false) + public object GetStaticResult(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, string contentType, Func> factoryFn, IDictionary responseHeaders = null, bool isHeadRequest = false) { if (cacheKey == Guid.Empty) { @@ -373,7 +373,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The request context. /// Type of the content. /// true if XXXX, false otherwise - private bool ShouldCompressResponse(IRequestContext requestContext, string contentType) + private bool ShouldCompressResponse(IRequest requestContext, string contentType) { // It will take some work to support compression with byte range requests if (!string.IsNullOrEmpty(requestContext.GetHeader("Range"))) @@ -428,9 +428,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// if set to true [compress]. /// if set to true [is head request]. /// Task{IHasOptions}. - private async Task GetStaticResult(IRequestContext requestContext, IDictionary responseHeaders, string contentType, Func> factoryFn, bool compress, bool isHeadRequest) + private async Task GetStaticResult(IRequest requestContext, IDictionary responseHeaders, string contentType, Func> factoryFn, bool compress, bool isHeadRequest) { - if (!compress || string.IsNullOrEmpty(requestContext.CompressionType)) + var requestedCompressionType = requestContext.GetCompressionType(); + + if (!compress || string.IsNullOrEmpty(requestedCompressionType)) { var stream = await factoryFn().ConfigureAwait(false); @@ -471,9 +473,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer return new HttpResult(content, contentType); } - var contents = content.Compress(requestContext.CompressionType); + var contents = content.Compress(requestedCompressionType); - return new CompressedResult(contents, requestContext.CompressionType, contentType); + return new CompressedResult(contents, requestedCompressionType, contentType); } /// @@ -548,7 +550,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The last date modified. /// Duration of the cache. /// true if [is not modified] [the specified cache key]; otherwise, false. - private bool IsNotModified(IRequestContext requestContext, Guid? cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration) + private bool IsNotModified(IRequest requestContext, Guid? cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration) { var isNotModified = true; -- cgit v1.2.3