aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-12-01 00:22:52 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-12-01 00:22:52 -0500
commite9686a56a607a9b8fca00a990063319ac0fe9138 (patch)
tree93de9a35d06dab446505350ef6d57e74b18a74c0 /MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs
parent843c9886aa5fedd015d0873b8dcfe0dbb7aff80c (diff)
update requirecss
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs')
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs37
1 files changed, 25 insertions, 12 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs
index 080441dda..4252d7aa8 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs
@@ -115,6 +115,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer
public object GetOptimizedResult<T>(IRequest requestContext, T result, IDictionary<string, string> responseHeaders = null)
where T : class
{
+ return GetOptimizedResultInternal<T>(requestContext, result, true, responseHeaders);
+ }
+
+ private object GetOptimizedResultInternal<T>(IRequest requestContext, T result, bool addCachePrevention, IDictionary<string, string> responseHeaders = null)
+ where T : class
+ {
if (result == null)
{
throw new ArgumentNullException("result");
@@ -122,20 +128,27 @@ namespace MediaBrowser.Server.Implementations.HttpServer
var optimizedResult = requestContext.ToOptimizedResult(result);
- if (responseHeaders != null)
+ if (responseHeaders == null)
{
- // Apply headers
- var hasOptions = optimizedResult as IHasOptions;
+ responseHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+ }
- if (hasOptions != null)
- {
- AddResponseHeaders(hasOptions, responseHeaders);
- }
+ if (addCachePrevention)
+ {
+ responseHeaders["Expires"] = "-1";
+ }
+
+ // Apply headers
+ var hasOptions = optimizedResult as IHasOptions;
+
+ if (hasOptions != null)
+ {
+ AddResponseHeaders(hasOptions, responseHeaders);
}
return optimizedResult;
}
-
+
/// <summary>
/// Gets the optimized result using cache.
/// </summary>
@@ -166,7 +179,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
if (responseHeaders == null)
{
- responseHeaders = new Dictionary<string, string>();
+ responseHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}
// See if the result is already cached in the browser
@@ -177,7 +190,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
return result;
}
- return GetOptimizedResult(requestContext, factoryFn(), responseHeaders);
+ return GetOptimizedResultInternal(requestContext, factoryFn(), false, responseHeaders);
}
/// <summary>
@@ -209,7 +222,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
if (responseHeaders == null)
{
- responseHeaders = new Dictionary<string, string>();
+ responseHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}
// See if the result is already cached in the browser
@@ -363,7 +376,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
public object GetStaticResult(IRequest requestContext, StaticResultOptions options)
{
var cacheKey = options.CacheKey;
- options.ResponseHeaders = options.ResponseHeaders ?? new Dictionary<string, string>();
+ options.ResponseHeaders = options.ResponseHeaders ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
var contentType = options.ContentType;
if (cacheKey == Guid.Empty)