A, HttpClient and HttpURLConnection, URLConnection
HttpURLConnection the URLConnection succession, the bottom socket, the most primitive communication, using an HTTP request HttpURLConnection greatest advantage is not necessary to introduce additional dependencies. But it can not provide additional functionality, such as cookie, log in, but also a lack of connection pool management, control and other mechanical properties of the domain name? Support.
Apache HttpClient is a project, a lot package level details. Apache HttpComponents HttpClient, formerly known as Apache Commons HttpClient, but Apache Commons HttpClient has stopped development, if you're still using it, switch to the Apache HttpComponents HttpClient up. Compared to traditional JDK comes with URLConnection HttpClient, increased ease of use and flexibility, it is not only the client sends an HTTP request easier, but also facilitates developers to test interface (Http-based protocol), is to enhance the development of efficiency, and convenience to improve the robustness of the code.
JDK comes HttpURLConnection standard library;. Apache HttpComponents HttpClient, and based on the warpper library, such as a non-Unirest HTTP client component library based on Apache HttpComponents HttpClient, a large number of code rewrite application layer, a typical representative OkHttp HttpURLConnectio..
Two, OKHttp
Since the current version of Apache HttpComponents HttpClient does not support HTTP / 2, and HTTP / 2 for mobile clients, whether it is from a handshake delay, response delay, or have considerable resource overhead look attractive. This therefore gives high-level package and supports http client lib HTTP / 2 enough living space. One of the most typical to the number of OkHttp.
OkHttp-friendly interface design, support HTTP / 2, and automatic detection and recovery mechanisms in the weak network and non-network environment, therefore, is one of the Android APP development of the most widely used HTTP clilent lib.
On the other hand, the interface provided by Java 9 OkHttp in HttpClint the interface more similar to (strictly speaking, should be the Java 9 draws on interface design OkHttp and other open source library?), Therefore, for those who like to reduce dependence, develop love for the native standard library who, in Java 11?, the OkHttp from switching to the standard library is relatively easy. Therefore, after to OkHttp represented http library usage scenarios may be eroded part.
Four, Volley
Volley google is introduced in the network communications conference 2013 io the frame, especially for small data processing amount, frequent communications network operation. Advantage is that the interior of the package asynchronous thread, the main thread may directly request the network, and returns the processing result. At the same time you can cancel the request, easily extensible. The disadvantages are: the face of a request large amounts of data, such as downloading poor performance, do not support https. Volley bottom, in use, the following system for android2.3 httpclicent, the requesting network HttpUrlConnection android2.3 used above. Can refer https://blog.csdn.net/guolin_blog/article/details/17482095
Five, Xutils
Xutils fire a few years ago was a relatively open-source framework, Xutils contains many useful tools, support for large file uploads, and more comprehensive request http protocol support, with flexible Orm, support event annotations and not affect code obfuscation . Xutils just come out when the program is really a lot of Cock wire ape welfare ah, integrates so many features powerful module, we really put it down, but with the upgrade and transformation of software development people thought of Android version, Xutils also exposed a lot of problems now with Xutils has not particularly much, if you want to use, then recommend the use of a relatively new Xutils3. Mainly for android, reference may https://blog.csdn.net/QPC908694753/article/details/77142124 .
Six, Retrofit
reference
https://juejin.im/post/5bae03b25188255c5442b66f
https://www.cnblogs.com/sharpest/p/7831350.html
https://blog.csdn.net/langtop/article/details/77972855