This library brings the latest platform-specific networking libraries to Xamarin applications via a custom HttpClient handler. Write your app using System.Net.Http, but drop this library in and it will go drastically faster. This is made possible by two native libraries:
- On iOS, NSURLSession
- On Android, via OkHttp 1.5
The good news is, you don't have to know either of these two libraries above, using ModernHttpClient is the most boring thing in the world. Here's how it works.
In your project references add System.Net.Http
.
using ModernHttpClient;
using System.Net.Http;
// NativeMessageHandler is the only class from ModernHttpClient that you need!
var httpClient = new HttpClient (new NativeMessageHandler ());
var response = httpClient.GetAsync ("http://httpbin.org/status/418").Result;
var responseContent = response.Content;
string responseString = responseContent.ReadAsStringAsync ().Result;
Console.WriteLine (responseString);
Just reference the Portable version of ModernHttpClient in your Portable Library, and it will use the correct version on all platforms.
make
## Run this first
make