diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-03-25 13:17:58 -0400 |
|---|---|---|
| committer | Luke <luke.pulverenti@gmail.com> | 2016-03-25 13:17:58 -0400 |
| commit | 89f86a0b2b017a011986f254dacbbac786dda3db (patch) | |
| tree | d31658b7fa861b2cb5f4b598f2692179c722e025 /MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs | |
| parent | 074192bae9c3ce76140db70805c232ff0296e067 (diff) | |
| parent | 20c72e0ce94798511db84882f7358476633ba23b (diff) | |
Merge pull request #1589 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs')
| -rw-r--r-- | MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs | 19 |
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; |
