From 4e79eaf65e8edb895f9337a8b878ff9ef312b3f6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 4 Dec 2013 09:52:38 -0500 Subject: add ApplicationPath to app paths interface to hide implementation --- .../HttpServer/HttpResultFactory.cs | 15 ++++++++++++++- .../HttpServer/SwaggerService.cs | 13 ++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index e6942fae6..5a5a2dd04 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -99,6 +99,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer return result; } + private bool SupportsCompression + { + get + { + return true; + } + } + /// /// Gets the optimized result. /// @@ -116,7 +124,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer throw new ArgumentNullException("result"); } - var optimizedResult = requestContext.ToOptimizedResult(result); + var optimizedResult = SupportsCompression ? requestContext.ToOptimizedResult(result) : result; if (responseHeaders != null) { @@ -458,6 +466,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer } } + if (!SupportsCompression) + { + return new HttpResult(content, contentType); + } + var contents = content.Compress(requestContext.CompressionType); return new CompressedResult(contents, requestContext.CompressionType, contentType); diff --git a/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs b/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs index 20728a30c..904b6799b 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs @@ -1,6 +1,6 @@ -using MediaBrowser.Common.Net; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Net; using ServiceStack.ServiceHost; -using System.Diagnostics; using System.IO; namespace MediaBrowser.Server.Implementations.HttpServer @@ -20,6 +20,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer public class SwaggerService : IHasResultFactory, IRestfulService { + private readonly IApplicationPaths _appPaths; + + public SwaggerService(IApplicationPaths appPaths) + { + _appPaths = appPaths; + } + /// /// Gets the specified request. /// @@ -27,7 +34,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// System.Object. public object Get(GetSwaggerResource request) { - var runningDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); + var runningDirectory = Path.GetDirectoryName(_appPaths.ApplicationPath); var swaggerDirectory = Path.Combine(runningDirectory, "swagger-ui"); -- cgit v1.2.3