jellyfin-server/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs

31 lines
951 B
C#
Raw Normal View History

2013-10-02 17:05:13 +00:00
using System;
using System.Net;
2013-09-25 00:54:51 +00:00
using System.Net.Cache;
using System.Net.Http;
namespace MediaBrowser.ServerApplication.Native
{
/// <summary>
2013-10-02 17:05:13 +00:00
/// Class HttpClientFactory
2013-09-25 00:54:51 +00:00
/// </summary>
2013-10-02 17:05:13 +00:00
public static class HttpClientFactory
2013-09-25 00:54:51 +00:00
{
/// <summary>
2013-10-02 17:05:13 +00:00
/// Gets the HTTP client.
2013-09-25 00:54:51 +00:00
/// </summary>
/// <param name="enableHttpCompression">if set to <c>true</c> [enable HTTP compression].</param>
2013-10-02 17:05:13 +00:00
/// <returns>HttpClient.</returns>
public static HttpClient GetHttpClient(bool enableHttpCompression)
2013-09-25 00:54:51 +00:00
{
2013-10-02 17:05:13 +00:00
return new HttpClient(new WebRequestHandler
2013-09-25 00:54:51 +00:00
{
CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate),
AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None
2013-10-02 17:05:13 +00:00
})
{
Timeout = TimeSpan.FromSeconds(20)
2013-09-25 00:54:51 +00:00
};
}
}
}