aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-06-07 17:21:30 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-06-07 17:21:30 -0400
commite8322b4a12652004a19835d0f27390ff1335da16 (patch)
tree75139e9ab384a7a9ea5150954e7e69b550638c14 /MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
parentc0125c03fd425e38eb7ecf7752aa585267a1fbbf (diff)
add mono CreateWebRequest workaround
Diffstat (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs')
-rw-r--r--MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
index b3a7f70bd..ae2148f08 100644
--- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
+++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs
@@ -105,6 +105,23 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
return client;
}
+ private WebRequest CreateWebRequest(string url)
+ {
+ try
+ {
+ return WebRequest.Create(url);
+ }
+ catch (NotSupportedException)
+ {
+ //Webrequest creation does fail on MONO randomly when using WebRequest.Create
+ //the issue occurs in the GetCreator method here: http://www.oschina.net/code/explore/mono-2.8.1/mcs/class/System/System.Net/WebRequest.cs
+
+ var type = Type.GetType("System.Net.HttpRequestCreator, System, Version=4.0.0.0,Culture=neutral, PublicKeyToken=b77a5c561934e089");
+ var creator = Activator.CreateInstance(type, nonPublic: true) as IWebRequestCreate;
+ return creator.Create(new Uri(url)) as HttpWebRequest;
+ }
+ }
+
private WebRequest GetRequest(HttpRequestOptions options, string method, bool enableHttpCompression)
{
var request = WebRequest.Create(options.Url);