diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
index 074994619c..c84239f92a 100644
--- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
+++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
@@ -80,7 +80,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
/// The host.
/// HttpClient.
/// host
- private HttpClient GetHttpClient(string host)
+ private HttpClient GetHttpClient(string host, bool enableHttpCompression)
{
if (string.IsNullOrEmpty(host))
{
@@ -88,17 +88,20 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
}
HttpClient client;
- if (!_httpClients.TryGetValue(host, out client))
+
+ var key = host + enableHttpCompression;
+
+ if (!_httpClients.TryGetValue(key, out client))
{
var handler = new WebRequestHandler
{
CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache),
- AutomaticDecompression = DecompressionMethods.None
+ AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None
};
client = new HttpClient(handler);
client.Timeout = TimeSpan.FromSeconds(20);
- _httpClients.TryAdd(host, client);
+ _httpClients.TryAdd(key, client);
}
return client;
@@ -182,7 +185,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
{
options.CancellationToken.ThrowIfCancellationRequested();
- var response = await GetHttpClient(GetHostFromUrl(options.Url)).SendAsync(message, HttpCompletionOption.ResponseHeadersRead, options.CancellationToken).ConfigureAwait(false);
+ var response = await GetHttpClient(GetHostFromUrl(options.Url), options.EnableHttpCompression).SendAsync(message, HttpCompletionOption.ResponseHeadersRead, options.CancellationToken).ConfigureAwait(false);
if (options.EnableResponseCache)
{
@@ -411,7 +414,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
{
cancellationToken.ThrowIfCancellationRequested();
- var msg = await GetHttpClient(GetHostFromUrl(url)).PostAsync(url, content, cancellationToken).ConfigureAwait(false);
+ var msg = await GetHttpClient(GetHostFromUrl(url), false).PostAsync(url, content, cancellationToken).ConfigureAwait(false);
EnsureSuccessStatusCode(msg);
@@ -472,7 +475,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
using (var message = GetHttpRequestMessage(options))
{
- using (var response = await GetHttpClient(GetHostFromUrl(options.Url)).SendAsync(message, HttpCompletionOption.ResponseHeadersRead, options.CancellationToken).ConfigureAwait(false))
+ using (var response = await GetHttpClient(GetHostFromUrl(options.Url), options.EnableHttpCompression).SendAsync(message, HttpCompletionOption.ResponseHeadersRead, options.CancellationToken).ConfigureAwait(false))
{
EnsureSuccessStatusCode(response);
diff --git a/MediaBrowser.Common/Net/HttpRequestOptions.cs b/MediaBrowser.Common/Net/HttpRequestOptions.cs
index f257b19752..7fb621b010 100644
--- a/MediaBrowser.Common/Net/HttpRequestOptions.cs
+++ b/MediaBrowser.Common/Net/HttpRequestOptions.cs
@@ -49,5 +49,12 @@ namespace MediaBrowser.Common.Net
///
/// true if [enable response caching]; otherwise, false.
public bool EnableResponseCache { get; set; }
+
+ public bool EnableHttpCompression { get; set; }
+
+ public HttpRequestOptions()
+ {
+ EnableHttpCompression = true;
+ }
}
}
diff --git a/MediaBrowser.Controller/Providers/Music/LastfmAlbumProvider.cs b/MediaBrowser.Controller/Providers/Music/LastfmAlbumProvider.cs
index 8ee2f4a267..0216c990fb 100644
--- a/MediaBrowser.Controller/Providers/Music/LastfmAlbumProvider.cs
+++ b/MediaBrowser.Controller/Providers/Music/LastfmAlbumProvider.cs
@@ -113,7 +113,8 @@ namespace MediaBrowser.Controller.Providers.Music
Url = url,
ResourcePool = LastfmResourcePool,
CancellationToken = cancellationToken,
- EnableResponseCache = true
+ EnableResponseCache = true,
+ EnableHttpCompression = false
}).ConfigureAwait(false))
{
diff --git a/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs b/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs
index 4fe7f522cf..ed2a09a4ff 100644
--- a/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs
+++ b/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs
@@ -98,7 +98,8 @@ namespace MediaBrowser.Controller.Providers.Music
Url = url,
ResourcePool = LastfmResourcePool,
CancellationToken = cancellationToken,
- EnableResponseCache = true
+ EnableResponseCache = true,
+ EnableHttpCompression = false
}).ConfigureAwait(false))
{
@@ -191,7 +192,8 @@ namespace MediaBrowser.Controller.Providers.Music
Url = url,
ResourcePool = LastfmResourcePool,
CancellationToken = cancellationToken,
- EnableResponseCache = true
+ EnableResponseCache = true,
+ EnableHttpCompression = false
}).ConfigureAwait(false))
{