From bb4c918bf8403b2058f5fbbf2c0b1943b4b5f327 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 2 Oct 2013 13:05:13 -0400 Subject: refactor http client factory for mono --- .../Native/HttpClientFactory.cs | 30 ++++++++++++++++++++++ .../Native/HttpMessageHandlerFactory.cs | 26 ------------------- 2 files changed, 30 insertions(+), 26 deletions(-) create mode 100644 MediaBrowser.ServerApplication/Native/HttpClientFactory.cs delete mode 100644 MediaBrowser.ServerApplication/Native/HttpMessageHandlerFactory.cs (limited to 'MediaBrowser.ServerApplication/Native') diff --git a/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs b/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs new file mode 100644 index 000000000..57f00ba03 --- /dev/null +++ b/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs @@ -0,0 +1,30 @@ +using System; +using System.Net; +using System.Net.Cache; +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(new WebRequestHandler + { + CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate), + AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None + }) + { + Timeout = TimeSpan.FromSeconds(20) + }; + } + } +} diff --git a/MediaBrowser.ServerApplication/Native/HttpMessageHandlerFactory.cs b/MediaBrowser.ServerApplication/Native/HttpMessageHandlerFactory.cs deleted file mode 100644 index 4bbcc9ea0..000000000 --- a/MediaBrowser.ServerApplication/Native/HttpMessageHandlerFactory.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Net; -using System.Net.Cache; -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 WebRequestHandler - { - CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate), - AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None - }; - } - } -} -- cgit v1.2.3