aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs')
-rw-r--r--MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs16
1 files changed, 12 insertions, 4 deletions
diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
index ae2148f08..7ca6f43d6 100644
--- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
+++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
@@ -432,7 +432,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
var httpResponse = (HttpWebResponse)response;
- EnsureSuccessStatusCode(httpResponse, options);
+ EnsureSuccessStatusCode(client, httpResponse, options);
options.CancellationToken.ThrowIfCancellationRequested();
@@ -443,7 +443,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
{
var httpResponse = (HttpWebResponse)response;
- EnsureSuccessStatusCode(httpResponse, options);
+ EnsureSuccessStatusCode(client, httpResponse, options);
options.CancellationToken.ThrowIfCancellationRequested();
@@ -629,7 +629,8 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
{
var httpResponse = (HttpWebResponse)response;
- EnsureSuccessStatusCode(httpResponse, options);
+ var client = GetHttpClient(GetHostFromUrl(options.Url), options.EnableHttpCompression);
+ EnsureSuccessStatusCode(client, httpResponse, options);
options.CancellationToken.ThrowIfCancellationRequested();
@@ -803,13 +804,20 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
return exception;
}
- private void EnsureSuccessStatusCode(HttpWebResponse response, HttpRequestOptions options)
+ private void EnsureSuccessStatusCode(HttpClientInfo client, HttpWebResponse response, HttpRequestOptions options)
{
var statusCode = response.StatusCode;
+
var isSuccessful = statusCode >= HttpStatusCode.OK && statusCode <= (HttpStatusCode)299;
if (!isSuccessful)
{
+ if ((int) statusCode == 429)
+ {
+ client.LastTimeout = DateTime.UtcNow;
+ }
+
+ if (statusCode == HttpStatusCode.RequestEntityTooLarge)
if (options.LogErrorResponseBody)
{
try