mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 03:26:07 +02:00
fix for missing response headers
This commit is contained in:
parent
539fecd08b
commit
8d4602035f
2 changed files with 21 additions and 27 deletions
|
@ -142,8 +142,6 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
throw new ArgumentNullException("result");
|
throw new ArgumentNullException("result");
|
||||||
}
|
}
|
||||||
|
|
||||||
var optimizedResult = ToOptimizedResult(requestContext, result);
|
|
||||||
|
|
||||||
if (responseHeaders == null)
|
if (responseHeaders == null)
|
||||||
{
|
{
|
||||||
responseHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
responseHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
@ -154,15 +152,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
responseHeaders["Expires"] = "-1";
|
responseHeaders["Expires"] = "-1";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply headers
|
return ToOptimizedResultInternal(requestContext, result, responseHeaders);
|
||||||
var hasHeaders = optimizedResult as IHasHeaders;
|
|
||||||
|
|
||||||
if (hasHeaders != null)
|
|
||||||
{
|
|
||||||
AddResponseHeaders(hasHeaders, responseHeaders);
|
|
||||||
}
|
|
||||||
|
|
||||||
return optimizedResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetCompressionType(IRequest request)
|
public static string GetCompressionType(IRequest request)
|
||||||
|
@ -189,6 +179,11 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public object ToOptimizedResult<T>(IRequest request, T dto)
|
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;
|
var contentType = request.ResponseContentType;
|
||||||
|
|
||||||
|
@ -197,11 +192,11 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
case "application/xml":
|
case "application/xml":
|
||||||
case "text/xml":
|
case "text/xml":
|
||||||
case "text/xml; charset=utf-8": //"text/xml; charset=utf-8" also matches 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 "application/json":
|
||||||
case "text/json":
|
case "text/json":
|
||||||
return _jsonSerializer.SerializeToString(dto);
|
return GetHttpResult(_jsonSerializer.SerializeToString(dto), contentType, false, responseHeaders);
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
var ms = new MemoryStream();
|
var ms = new MemoryStream();
|
||||||
|
@ -213,10 +208,10 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
|
|
||||||
if (string.Equals(request.Verb, "head", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(request.Verb, "head", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return GetHttpResult(new byte[] { }, contentType, true);
|
return GetHttpResult(new byte[] { }, contentType, true, responseHeaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetHttpResult(ms, contentType, true);
|
return GetHttpResult(ms, contentType, true, responseHeaders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using Emby.Drawing;
|
using Emby.Drawing;
|
||||||
using Emby.Drawing.Skia;
|
using Emby.Drawing.Skia;
|
||||||
using Emby.Server.Core;
|
|
||||||
using Emby.Server.Implementations;
|
using Emby.Server.Implementations;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
|
|
Loading…
Reference in a new issue