From 0d025f7fb620bf2a24ca9aa4e5994f132e02e7c0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 6 May 2014 22:28:19 -0400 Subject: beginning remote subtitle downloading --- .../HttpClientManager/HttpClientManager.cs | 13 +++++++++---- .../ScheduledTasks/Tasks/DeleteCacheFileTask.cs | 6 ++++-- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'MediaBrowser.Common.Implementations') diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index a88f457c5..0a9f0ff8a 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -114,9 +114,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager request.AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None; - request.CachePolicy = options.CachePolicy == Net.HttpRequestCachePolicy.None ? - new RequestCachePolicy(RequestCacheLevel.BypassCache) : - new RequestCachePolicy(RequestCacheLevel.Revalidate); + request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache); request.ConnectionGroupName = GetHostFromUrl(options.Url); request.KeepAlive = true; @@ -124,6 +122,11 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager request.Pipelined = true; request.Timeout = 20000; + if (!string.IsNullOrEmpty(options.Host)) + { + request.Host = options.Host; + } + #if !__MonoCS__ // This is a hack to prevent KeepAlive from getting disabled internally by the HttpWebRequest // May need to remove this for mono @@ -234,9 +237,11 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager !string.IsNullOrEmpty(options.RequestContent) || string.Equals(httpMethod, "post", StringComparison.OrdinalIgnoreCase)) { - var bytes = options.RequestContentBytes ?? Encoding.UTF8.GetBytes(options.RequestContent ?? string.Empty); + var bytes = options.RequestContentBytes ?? + Encoding.UTF8.GetBytes(options.RequestContent ?? string.Empty); httpWebRequest.ContentType = options.RequestContentType ?? "application/x-www-form-urlencoded"; + httpWebRequest.ContentLength = bytes.Length; httpWebRequest.GetRequestStream().Write(bytes, 0, bytes.Length); } diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs index a5b8de554..dbeedfed5 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks private readonly ILogger _logger; private readonly IFileSystem _fileSystem; - + /// /// Initializes a new instance of the class. /// @@ -74,9 +74,11 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks progress.Report(90); + minDateModified = DateTime.UtcNow.AddDays(-3); + try { - DeleteCacheFilesFromDirectory(cancellationToken, ApplicationPaths.TempDirectory, DateTime.MaxValue, progress); + DeleteCacheFilesFromDirectory(cancellationToken, ApplicationPaths.TempDirectory, minDateModified, progress); } catch (DirectoryNotFoundException) { -- cgit v1.2.3