diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index 4c2d5d599f..4a614f42d5 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -332,7 +332,7 @@ namespace MediaBrowser.Common.Implementations
RegisterSingleInstance(TaskManager);
- HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger, GetHttpMessageHandler);
+ HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger, CreateHttpClient);
RegisterSingleInstance(HttpClient);
NetworkManager = new NetworkManager();
@@ -352,7 +352,7 @@ namespace MediaBrowser.Common.Implementations
});
}
- protected abstract HttpMessageHandler GetHttpMessageHandler(bool enableHttpCompression);
+ protected abstract HttpClient CreateHttpClient(bool enableHttpCompression);
///
/// Gets a list of types within an assembly
diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
index 3a626000fd..412c695096 100644
--- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
+++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
@@ -31,21 +31,22 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
///
private readonly IApplicationPaths _appPaths;
- public delegate HttpMessageHandler GetHttpMessageHandler(bool enableHttpCompression);
+ public delegate HttpClient GetHttpClientHandler(bool enableHttpCompression);
- private readonly GetHttpMessageHandler _getHttpMessageHandler;
+ private readonly GetHttpClientHandler _getHttpClientHandler;
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- /// The kernel.
+ /// The app paths.
/// The logger.
+ /// The get HTTP client handler.
///
/// appPaths
/// or
/// logger
///
- public HttpClientManager(IApplicationPaths appPaths, ILogger logger, GetHttpMessageHandler getHttpMessageHandler)
+ public HttpClientManager(IApplicationPaths appPaths, ILogger logger, GetHttpClientHandler getHttpClientHandler)
{
if (appPaths == null)
{
@@ -57,7 +58,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
}
_logger = logger;
- _getHttpMessageHandler = getHttpMessageHandler;
+ _getHttpClientHandler = getHttpClientHandler;
_appPaths = appPaths;
}
@@ -90,10 +91,8 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
{
client = new HttpClientInfo
{
- HttpClient = new HttpClient(_getHttpMessageHandler(enableHttpCompression))
- {
- Timeout = TimeSpan.FromSeconds(20)
- }
+
+ HttpClient = _getHttpClientHandler(enableHttpCompression)
};
_httpClients.TryAdd(key, client);
}
diff --git a/MediaBrowser.Mono.userprefs b/MediaBrowser.Mono.userprefs
index 4766c133a0..6275e35458 100644
--- a/MediaBrowser.Mono.userprefs
+++ b/MediaBrowser.Mono.userprefs
@@ -1,11 +1,11 @@
-
+
-
+
diff --git a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
index af3d72d695..4fd158f4e4 100644
--- a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
+++ b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
@@ -81,9 +81,9 @@
ApplicationHost.cs
-
+
diff --git a/MediaBrowser.Server.Mono/Native/HttpClientFactory.cs b/MediaBrowser.Server.Mono/Native/HttpClientFactory.cs
new file mode 100644
index 0000000000..0fceab0608
--- /dev/null
+++ b/MediaBrowser.Server.Mono/Native/HttpClientFactory.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Net.Http;
+
+namespace MediaBrowser.ServerApplication.Native
+{
+ ///
+ /// Class HttpClientFactory
+ ///
+ public static class HttpClientFactory
+ {
+ ///
+ /// Gets the HTTP client.
+ ///
+ /// if set to true [enable HTTP compression].
+ /// HttpClient.
+ public static HttpClient GetHttpClient(bool enableHttpCompression)
+ {
+ return new HttpClient()
+ {
+ Timeout = TimeSpan.FromSeconds(20)
+ };
+ }
+ }
+}
diff --git a/MediaBrowser.Server.Mono/Native/HttpMessageHandlerFactory.cs b/MediaBrowser.Server.Mono/Native/HttpMessageHandlerFactory.cs
deleted file mode 100644
index 627218a01c..0000000000
--- a/MediaBrowser.Server.Mono/Native/HttpMessageHandlerFactory.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System.Net;
-using System.Net.Http;
-
-namespace MediaBrowser.ServerApplication.Native
-{
- ///
- /// Class HttpMessageHandlerFactory
- ///
- public static class HttpMessageHandlerFactory
- {
- ///
- /// Gets the HTTP message handler.
- ///
- /// if set to true [enable HTTP compression].
- /// HttpMessageHandler.
- public static HttpMessageHandler GetHttpMessageHandler(bool enableHttpCompression)
- {
- return new HttpClientHandler
- {
- AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None
- };
- }
- }
-}
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index 9e13e548ad..a624fc18c4 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -672,14 +672,9 @@ namespace MediaBrowser.ServerApplication
OnApplicationUpdated(package.version);
}
- ///
- /// Gets the HTTP message handler.
- ///
- /// if set to true [enable HTTP compression].
- /// HttpMessageHandler.
- protected override HttpMessageHandler GetHttpMessageHandler(bool enableHttpCompression)
+ protected override HttpClient CreateHttpClient(bool enableHttpCompression)
{
- return HttpMessageHandlerFactory.GetHttpMessageHandler(enableHttpCompression);
+ return HttpClientFactory.GetHttpClient(enableHttpCompression);
}
protected override void ConfigureAutoRunAtStartup(bool autorun)
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
index cbcb3ac25c..efc3adf568 100644
--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
@@ -188,7 +188,7 @@
-
+
diff --git a/MediaBrowser.ServerApplication/Native/HttpMessageHandlerFactory.cs b/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs
similarity index 58%
rename from MediaBrowser.ServerApplication/Native/HttpMessageHandlerFactory.cs
rename to MediaBrowser.ServerApplication/Native/HttpClientFactory.cs
index 4bbcc9ea09..57f00ba03b 100644
--- a/MediaBrowser.ServerApplication/Native/HttpMessageHandlerFactory.cs
+++ b/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs
@@ -1,25 +1,29 @@
-using System.Net;
+using System;
+using System.Net;
using System.Net.Cache;
using System.Net.Http;
namespace MediaBrowser.ServerApplication.Native
{
///
- /// Class HttpMessageHandlerFactory
+ /// Class HttpClientFactory
///
- public static class HttpMessageHandlerFactory
+ public static class HttpClientFactory
{
///
- /// Gets the HTTP message handler.
+ /// Gets the HTTP client.
///
/// if set to true [enable HTTP compression].
- /// HttpMessageHandler.
- public static HttpMessageHandler GetHttpMessageHandler(bool enableHttpCompression)
+ /// HttpClient.
+ public static HttpClient GetHttpClient(bool enableHttpCompression)
{
- return new WebRequestHandler
+ return new HttpClient(new WebRequestHandler
{
CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate),
AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None
+ })
+ {
+ Timeout = TimeSpan.FromSeconds(20)
};
}
}