I have made several apps and libraries for Android
that use HttpUriRequest to create network requests (for example, my droidQuery library), however I have been seeing some new libraries emerging (such as OkHttp, which is meant to be extraordinarily fast) that use HttpURLConnection instead.
Does HttpURLConnection
provide a faster connection than HttpUriRequest
, or are these two classes basically equivalent? What are the pros and cons to using one over the other?
This is answered on the Android Dev Blog:
Apache HTTP client has fewer bugs on Eclair and Froyo. It is the best choice for these releases.
For Gingerbread and better, HttpURLConnection is the best choice. Its simple API and small size makes it great fit for Android. Transparent compression and response caching reduce network use, improve speed and save battery. New applications should use HttpURLConnection; it is where we will be spending our energy going forward.