aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-02 13:05:13 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-02 13:05:13 -0400
commitbb4c918bf8403b2058f5fbbf2c0b1943b4b5f327 (patch)
tree1c14879511e69a5a989ccf95f2de491f5b3eb9d2 /MediaBrowser.ServerApplication/Native/HttpClientFactory.cs
parent9f8a1b30a1ecec0af3c48bcb30e035938f93218c (diff)
refactor http client factory for mono
Diffstat (limited to 'MediaBrowser.ServerApplication/Native/HttpClientFactory.cs')
-rw-r--r--MediaBrowser.ServerApplication/Native/HttpClientFactory.cs30
1 files changed, 30 insertions, 0 deletions
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
+{
+ /// <summary>
+ /// Class HttpClientFactory
+ /// </summary>
+ public static class HttpClientFactory
+ {
+ /// <summary>
+ /// Gets the HTTP client.
+ /// </summary>
+ /// <param name="enableHttpCompression">if set to <c>true</c> [enable HTTP compression].</param>
+ /// <returns>HttpClient.</returns>
+ 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)
+ };
+ }
+ }
+}