mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-10 04:06:17 +00:00
refactor http client factory for mono
This commit is contained in:
30
MediaBrowser.ServerApplication/Native/HttpClientFactory.cs
Normal file
30
MediaBrowser.ServerApplication/Native/HttpClientFactory.cs
Normal file
@@ -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)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user