diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-09-28 13:05:10 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-09-28 13:05:10 -0400 |
| commit | 8d4602035f48e5d00d3145b3e7b6a7075d627b7f (patch) | |
| tree | 4246d995d309045c9c90debb81d2c391ff80bb6c | |
| parent | 539fecd08b752a50ebdbcef45b51a998f1390167 (diff) | |
fix for missing response headers
| -rw-r--r-- | Emby.Server.Implementations/HttpServer/HttpResultFactory.cs | 43 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/ImageEncoderHelper.cs | 1 |
2 files changed, 19 insertions, 25 deletions
diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs index a70aad14e..86deccee1 100644 --- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -142,8 +142,6 @@ namespace Emby.Server.Implementations.HttpServer throw new ArgumentNullException("result"); } - var optimizedResult = ToOptimizedResult(requestContext, result); - if (responseHeaders == null) { responseHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); @@ -154,15 +152,7 @@ namespace Emby.Server.Implementations.HttpServer responseHeaders["Expires"] = "-1"; } - // Apply headers - var hasHeaders = optimizedResult as IHasHeaders; - - if (hasHeaders != null) - { - AddResponseHeaders(hasHeaders, responseHeaders); - } - - return optimizedResult; + return ToOptimizedResultInternal(requestContext, result, responseHeaders); } public static string GetCompressionType(IRequest request) @@ -190,6 +180,11 @@ namespace Emby.Server.Implementations.HttpServer /// <returns></returns> public object ToOptimizedResult<T>(IRequest request, T dto) { + return ToOptimizedResultInternal(request, dto, null); + } + + private object ToOptimizedResultInternal<T>(IRequest request, T dto, IDictionary<string, string> responseHeaders = null) + { var contentType = request.ResponseContentType; switch (GetRealContentType(contentType)) @@ -197,27 +192,27 @@ namespace Emby.Server.Implementations.HttpServer case "application/xml": case "text/xml": case "text/xml; charset=utf-8": //"text/xml; charset=utf-8" also matches xml - return SerializeToXmlString(dto); + return GetHttpResult(SerializeToXmlString(dto), contentType, false, responseHeaders); case "application/json": case "text/json": - return _jsonSerializer.SerializeToString(dto); + return GetHttpResult(_jsonSerializer.SerializeToString(dto), contentType, false, responseHeaders); default: - { - var ms = new MemoryStream(); - var writerFn = RequestHelper.GetResponseWriter(HttpListenerHost.Instance, contentType); + { + var ms = new MemoryStream(); + var writerFn = RequestHelper.GetResponseWriter(HttpListenerHost.Instance, contentType); - writerFn(dto, ms); - - ms.Position = 0; + writerFn(dto, ms); - if (string.Equals(request.Verb, "head", StringComparison.OrdinalIgnoreCase)) - { - return GetHttpResult(new byte[] { }, contentType, true); - } + ms.Position = 0; - return GetHttpResult(ms, contentType, true); + if (string.Equals(request.Verb, "head", StringComparison.OrdinalIgnoreCase)) + { + return GetHttpResult(new byte[] { }, contentType, true, responseHeaders); } + + return GetHttpResult(ms, contentType, true, responseHeaders); + } } } diff --git a/MediaBrowser.ServerApplication/ImageEncoderHelper.cs b/MediaBrowser.ServerApplication/ImageEncoderHelper.cs index 0e99bbbad..c86e85785 100644 --- a/MediaBrowser.ServerApplication/ImageEncoderHelper.cs +++ b/MediaBrowser.ServerApplication/ImageEncoderHelper.cs @@ -1,7 +1,6 @@ using System; using Emby.Drawing; using Emby.Drawing.Skia; -using Emby.Server.Core; using Emby.Server.Implementations; using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Net; |
