aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2015-09-02 11:50:00 -0400
committerLuke <luke.pulverenti@gmail.com>2015-09-02 11:50:00 -0400
commitf868dd81e856488280978006cbb67afc2677049d (patch)
tree616ba8ae846efe9ec889abeb12f6b2702c6b8592 /MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
parentaf89446c20fb302087b82c18c28da92076dbc5ac (diff)
parente6d5901408ba7d8e344a27ea1f3b0046c40e56c1 (diff)
Merge pull request #1164 from MediaBrowser/dev
3.0.5724.1
Diffstat (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs')
-rw-r--r--MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs21
1 files changed, 16 insertions, 5 deletions
diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
index ae2148f08..89f405e8a 100644
--- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
+++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
@@ -68,6 +68,9 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
// http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c
ServicePointManager.Expect100Continue = false;
+
+ // Trakt requests sometimes fail without this
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
}
/// <summary>
@@ -124,7 +127,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
private WebRequest GetRequest(HttpRequestOptions options, string method, bool enableHttpCompression)
{
- var request = WebRequest.Create(options.Url);
+ var request = CreateWebRequest(options.Url);
var httpWebRequest = request as HttpWebRequest;
if (httpWebRequest != null)
@@ -432,7 +435,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
var httpResponse = (HttpWebResponse)response;
- EnsureSuccessStatusCode(httpResponse, options);
+ EnsureSuccessStatusCode(client, httpResponse, options);
options.CancellationToken.ThrowIfCancellationRequested();
@@ -443,7 +446,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
{
var httpResponse = (HttpWebResponse)response;
- EnsureSuccessStatusCode(httpResponse, options);
+ EnsureSuccessStatusCode(client, httpResponse, options);
options.CancellationToken.ThrowIfCancellationRequested();
@@ -629,7 +632,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 +807,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