Skip to content

ModernHttpClient 2.0.0

Compare
Choose a tag to compare
@anaisbetts anaisbetts released this 19 May 21:47
· 126 commits to master since this release

What's New

Built-in Portable Library Support

ModernHttpClient 2.0 now makes it even easier to use inside a portable library (PCL) project. Instead of the workarounds previously listed in the README, you now can just use a new class everywhere:

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

On Windows-based platforms, this will still work but be a no-op (i.e. it will use the underlying default HttpMessageHandler).

Download progress

Thanks to @nberardi (#59), ModernHttpClient now makes it easier to track the progress of large downloads:

var handler = new NativeMessageHandler();
var request = new HttpRequestMessage(HttpMethod.Get, url);
handler.RegisterForProgress(request, HandleDownloadProgress);

void HandleDownloadProgress(long bytesInThisChunk, long totalBytesDownloaded, long totalBytesExpected)
{
}

Captive Network Detection

ModernHttpClient now extends Captive Network detection to both iOS and Android, thanks to @molinch (#60). If enabled via the NativeMessageHandler constructor parameter, an exception will be thrown if a request is redirected to a different domain (i.e. if the user is at a coffee shop and is being presented with a "Please Sign In" dialog).

This defaults to false because there are non-captive network cases where a redirect will send you to a different domain (for example, downloading a file from S3). If you're using HttpClient with a REST API that you know won't redirect you off-domain, this is good to enable.

Bug Fixes

  • Handle connection failures and timeouts better (#49, thanks @guillaume-fr)
  • Correctly pass through cancellation to more methods (#51, thanks @nberardi)
  • Correctly bump the OkHttp version