diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index 0bd61dbc20..37db80ee35 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -19,6 +19,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Net.Http;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
@@ -272,7 +273,7 @@ namespace MediaBrowser.Common.Implementations
RegisterSingleInstance(TaskManager);
- HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger);
+ HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger, GetHttpMessageHandler);
RegisterSingleInstance(HttpClient);
NetworkManager = new NetworkManager();
@@ -286,6 +287,8 @@ namespace MediaBrowser.Common.Implementations
});
}
+ protected abstract HttpMessageHandler GetHttpMessageHandler(bool enableHttpCompression);
+
///
/// Gets a list of types within an assembly
/// This will handle situations that would normally throw an exception - such as a type within the assembly that depends on some other non-existant reference
diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
index 82c385522f..9eab2cdd89 100644
--- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
+++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
@@ -9,8 +9,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
-using System.Net;
-using System.Net.Cache;
using System.Net.Http;
using System.Text;
using System.Threading;
@@ -33,6 +31,10 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
///
private readonly IApplicationPaths _appPaths;
+ public delegate HttpMessageHandler GetHttpMessageHandler(bool enableHttpCompression);
+
+ private readonly GetHttpMessageHandler _getHttpMessageHandler;
+
///
/// Initializes a new instance of the class.
///
@@ -43,7 +45,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
/// or
/// logger
///
- public HttpClientManager(IApplicationPaths appPaths, ILogger logger)
+ public HttpClientManager(IApplicationPaths appPaths, ILogger logger, GetHttpMessageHandler getHttpMessageHandler)
{
if (appPaths == null)
{
@@ -55,6 +57,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
}
_logger = logger;
+ _getHttpMessageHandler = getHttpMessageHandler;
_appPaths = appPaths;
}
@@ -85,15 +88,9 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
if (!_httpClients.TryGetValue(key, out client))
{
- var handler = new WebRequestHandler
- {
- CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate),
- AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None
- };
-
client = new HttpClientInfo
{
- HttpClient = new HttpClient(handler)
+ HttpClient = new HttpClient(_getHttpMessageHandler(enableHttpCompression))
{
Timeout = TimeSpan.FromSeconds(20)
}
diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
index a21a0790a6..d0365fce47 100644
--- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
+++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
@@ -54,7 +54,6 @@
-
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index 4991db8e2d..ed4900128a 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
@@ -101,9 +101,9 @@
..\packages\Rx-Linq.2.1.30214.0\lib\Net45\System.Reactive.Linq.dll
-
+
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index eb8a730496..b77c738c37 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -50,6 +50,9 @@ using System.Data.SQLite;
using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Net;
+using System.Net.Cache;
+using System.Net.Http;
using System.Reflection;
using System.Threading.Tasks;
@@ -660,5 +663,14 @@ namespace MediaBrowser.ServerApplication
{
get { return Constants.MbServerPkgName; }
}
+
+ protected override HttpMessageHandler GetHttpMessageHandler(bool enableHttpCompression)
+ {
+ return new WebRequestHandler
+ {
+ CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate),
+ AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None
+ };
+ }
}
}
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
index 912db757a2..c84d840d14 100644
--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
@@ -184,6 +184,8 @@
+
+