Extend HttpClient to use infrastructure in Xamarin.Mac (via reflection) to pick right...
authorRolf Bjarne Kvinge <rolf@xamarin.com>
Tue, 15 Mar 2016 12:29:33 +0000 (13:29 +0100)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 28 Mar 2016 22:51:36 +0000 (15:51 -0700)
List of original contributors:

Chris Hamons <chris.hamons@xamarin.com>

mcs/class/System.Net.Http/System.Net.Http/HttpClient.mac.cs [new file with mode: 0644]
mcs/class/System.Net.Http/xammac_System.Net.Http.dll.sources
mcs/class/System.Net.Http/xammac_net_4_5_System.Net.Http.dll.sources

diff --git a/mcs/class/System.Net.Http/System.Net.Http/HttpClient.mac.cs b/mcs/class/System.Net.Http/System.Net.Http/HttpClient.mac.cs
new file mode 100644 (file)
index 0000000..42f664c
--- /dev/null
@@ -0,0 +1,23 @@
+using System;
+using System.Reflection;
+
+[assembly:System.Runtime.CompilerServices.InternalsVisibleTo ("Xamarin.Mac, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
+
+namespace System.Net.Http {
+       public partial class HttpClient {
+
+               public HttpClient ()
+                       : this (GetDefaultHandler (), true)
+               {
+               }
+
+               // note: the linker will re-write ObjCRuntime.RuntimeOptions.GetHttpMessageHandler to return the correct type
+               // unlike, XI where this method itself gets rewritten during linking
+               static HttpMessageHandler GetDefaultHandler ()
+               {
+                       Type type = Type.GetType("ObjCRuntime.RuntimeOptions, Xamarin.Mac");
+                       var method = type.GetMethod ("GetHttpMessageHandler", BindingFlags.Static | BindingFlags.NonPublic);
+                       return (HttpMessageHandler)method.Invoke (null, null);
+               }
+       }
+}
index fbffe9e7634bb2e8d42c512f49453edf60a03b1e..216e48da9cdbcb384ba0ecc8b3c4aa814c2f4ce5 100644 (file)
@@ -1 +1,2 @@
 #include System.Net.Http.dll.sources
+System.Net.Http/HttpClient.mac.cs
index fbffe9e7634bb2e8d42c512f49453edf60a03b1e..216e48da9cdbcb384ba0ecc8b3c4aa814c2f4ce5 100644 (file)
@@ -1 +1,2 @@
 #include System.Net.Http.dll.sources
+System.Net.Http/HttpClient.mac.cs