androidhttpandroid-networking

What is HttpEngine in android.net.http


I noticed there are new class in the android.net.http package. Some of them are added in API 34, also in the S Extensions 7. I encountered the HttpEngine class in the package, the summary says that

An engine to process UrlRequests, which uses the best HTTP stack available on the current platform. An instance of this class can be created using HttpEngine.Builder.

Is this class noteworthy? What is meant by "best HTTP stack", would it perform better than typical HTTP client we use like OkHttp?


Solution

  • HttpEngine is an Android SDK version of Cronet: https://developer.android.com/develop/connectivity/cronet

    It is essentially the same networking client that powers Google Chrome and other Chromium-based browsers. It offers HTTP/3, and performs very well when connection is low quality, or a phone is on the move and switching between different networks.

    Cronet has been around for many years, but its now introduced into the SDK and much easier to link with. There isn't a ton of documentation specific for it yet, because API 34 is <15% of the market - but everything written for Cronet should work with HttpEngine, and there are more updates coming as more devices are getting the relevant update.