Extend HttpClient to use infrastructure in Xamarin.Mac (via reflection) to pick right...
[mono.git] / mcs / class / System.Net.Http / System.Net.Http / HttpClient.mac.cs
1 using System;
2 using System.Reflection;
3
4 [assembly:System.Runtime.CompilerServices.InternalsVisibleTo ("Xamarin.Mac, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
5
6 namespace System.Net.Http {
7         public partial class HttpClient {
8
9                 public HttpClient ()
10                         : this (GetDefaultHandler (), true)
11                 {
12                 }
13
14                 // note: the linker will re-write ObjCRuntime.RuntimeOptions.GetHttpMessageHandler to return the correct type
15                 // unlike, XI where this method itself gets rewritten during linking
16                 static HttpMessageHandler GetDefaultHandler ()
17                 {
18                         Type type = Type.GetType("ObjCRuntime.RuntimeOptions, Xamarin.Mac");
19                         var method = type.GetMethod ("GetHttpMessageHandler", BindingFlags.Static | BindingFlags.NonPublic);
20                         return (HttpMessageHandler)method.Invoke (null, null);
21                 }
22         }
23 }