35 ratings
  • 1
  • 2
  • 3
  • 4
  • 5
5 star 28
4 star 4
3 star 2
2 star 1
1 star 0
Compatible with
  • iOS
  • Android

ModernHttpClient 2.4.2

Paul Betts

Write your app using System.Net.Http, but drop this library in and it will go drastically faster.

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, via NSURLSession
  • On Android, via OkHttp 1.5

Usage

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:

var httpClient = new HttpClient(new NativeMessageHandler());

Release Notes

What's New

Bug Fixes

  • Pass the hostname to ServerCertificateValidatorCallback (#152, thanks @Tableau-David-Potter)
Write a Review

16 reviews

David Underwood rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Massive improvement on HttpClient, thank you!

Posted on: March 24 / Version: 2.4.2
Andrew Wright rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Great piece of work here Paul. I've got a question on file download capabilities of this thing. I have a bunch of DOTNET code based around the HttpWebRequest object that does a great job of picking up downloads where they left off. For example, I'm downloading a 50 MB file and I lose my internet connection briefly after downloading 25MB of it. Once my device reconnects it picks up from 25MB and keeps going. The critical piece of this is the AddRange method on the HttpWebRequest. I did some hunting around and did not find anything like that in your library. Is this possible with the ModernHttpClient? If so can you point me in the right direction? Thanks Paul ...

Posted on: February 3 / Version: 2.4.2
Nina Kharchenko rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Had to stop usage of NativeMessageHandler due to it doesn't takes into account Timeout property of HttpClient (at least Android version).

Posted on: September 3, 2016 / Version: 2.4.2
Trevor Cox rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Does it work with IPv6? Also would be nice to document the minimum required versions of iOS and Android.

Posted on: August 22, 2016 / Version: 2.4.2
ITTrendex dev account rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

It helped me a lot

Posted on: June 21, 2016 / Version: 2.4.2
pedro pedro rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Wow!! Really fast! Thank you

Posted on: August 14, 2015 / Version: 2.4.2
Nathan Channon rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Is there a way of retrieving the proxy settings from the httpclient? I'm assuming from the comment below that this now makes httpclient proxy-aware automagically but can we retrieve the proxy settings to pass to the aws sdk?

Thanks

Posted on: July 24, 2015 / Version: 2.4.2
Stephen Robinson

I've downloaded the trial Pro version to see if it helps with SSL handshake issues in Android. However, I do not see instructions on how to enable the trial. When I invoke NativeMessageHandler.EnableUntrustedCertificates(), I get this message: "Purchase the full version to enable untrusted certificates!"

Posted on: July 1, 2015 / Version: 2.4.2
Ahmed Hassan rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Nice one, man, just wanted to let you know that your client fixes a horrible bug that's found in Mono. You can read about it here:

https://bugzilla.xamarin.com/show_bug.cgi?id=30604 https://bugzilla.xamarin.com/show_bug.cgi?id=22384 https://forums.xamarin.com/discussion/42410/bug-httpclient-times-out-when-redirected-on-a-post-request

Dropping your client handler makes it all work fine. If only I had found it before wasting days writing a client handler manually to fix it...

Posted on: June 7, 2015 / Version: 2.4.2
ahmed khan rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

It definitely appears to be faster than a standard client.. I tested this library using some Test ODATA queries (see code here: https://github.com/ahmedkhan25/NativeODATAClientTester )

Posted on: May 25, 2015 / Version: 2.4.2
Ted Rogers rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

@Paul Betts: How would I use ModernHttpClient with a self-signed certificate? I have the ServicePointManager.ServerCertificateValidationCallback return true with HttpClient but this doesn't seem to work to ModernHttpClient.

Posted on: January 4, 2015 / Version: 2.1.4
Stephan van Rooij rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

My app actually got a lot faster. Thanks for that!!

But the credential part took me some time to figure out. Maybe your should create an example about how to pre-authenticate a http connection.

Posted on: June 26, 2014 / Version: 2.0.1
Paul Betts rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

@Mustafa: ModernHttpClient automatically supports the system proxy settings, you don't have to set a "UseProxy" boolean

@Andrius: There's a bug filed for this and it will hopefully be fixed soon

Posted on: May 27, 2014 / Version: 2.0.1
Mustafa Shaik

How can I set the proxy for the HttpClient, just as the similar code,

var handler = new HttpClientHandler { Proxy = CFNetwork.GetDefaultProxy, UseProxy = true };

this.client = new HttpClient(handler);

Posted on: May 27, 2014 / Version: 2.0.1
Andrius Bu

Any ideas how to make this component work in the development environment with a self signed certificate?

Posted on: April 2, 2014 / Version: 1.2.2
Tomasz Cielecki rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Really makes for a great experience using ModernHttpClient in your app. Faster and more stable downloads! If you are interested in a plugin for MvvmCross using this library, visit: https://github.com/Cheesebaron/Cheesebaron.MvxPlugins

Keep up the great work Paul!

Posted on: March 31, 2014 / Version: 1.0.1