aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/HttpClientManager
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-03-25 13:52:15 -0400
committerLuke <luke.pulverenti@gmail.com>2016-03-25 13:52:15 -0400
commit72fe76ab1008f0bd38157cc37cde45797b5f6417 (patch)
tree875b6bee7d0a634d7ef019cfb7c434823b223001 /MediaBrowser.Common.Implementations/HttpClientManager
parent736e63241011cb9ae798bf4091cd37e097045c21 (diff)
parentf6c18200bacae6e768225a8c073418a170d349bd (diff)
Merge pull request #1593 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.Common.Implementations/HttpClientManager')
-rw-r--r--MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
index c30cdf1a7..f9dbd766f 100644
--- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
+++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
@@ -126,6 +126,23 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
}
}
+ private void AddIpv4Option(HttpWebRequest request, HttpRequestOptions options)
+ {
+ if (!options.PreferIpv4)
+ {
+ return;
+ }
+
+ request.ServicePoint.BindIPEndPointDelegate = (servicePount, remoteEndPoint, retryCount) =>
+ {
+ if (remoteEndPoint.AddressFamily == AddressFamily.InterNetwork)
+ {
+ return new IPEndPoint(IPAddress.Any, 0);
+ }
+ throw new InvalidOperationException("no IPv4 address");
+ };
+ }
+
private WebRequest GetRequest(HttpRequestOptions options, string method, bool enableHttpCompression)
{
var request = CreateWebRequest(options.Url);
@@ -133,6 +150,8 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
if (httpWebRequest != null)
{
+ AddIpv4Option(httpWebRequest, options);
+
AddRequestHeaders(httpWebRequest, options);
httpWebRequest.AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None;