Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Okhttp or HTTPClient : Which offers better functionality and more efficiency? [closed]

To make a http request, there're some APIs alternative in JAVA, such as Apache HttpClient and Okhttp. Apache HttpClient is mature and widely used, and Okhttp seems to be more and more popular(I'm not sure).

What I wondered is, which is better, or does Apache HttpClient has some feature that Okhttp doesn't have, or the other way round? Mostly, I'm talking in server side, it's also very nice to talk about using in Android App.

I hope some points could be listed, therefore I can figure out the differences between Apache HttpClient and Okhttp.

Reference:

There's a question between URLConnection and HttpClient: URLConnection or HTTPClient : Which offers better functionality and more efficiency?

like image 957
Coderec Avatar asked Feb 22 '17 13:02

Coderec


1 Answers

I suggest to use okhttp. Here is the reason: https://github.com/square/okhttp/issues/3472

OkHttp has HTTP/2, a built-in response cache, web sockets, and a simpler API. It’s got better defaults and is easier to use efficiently. It’s got a better URL model, a better cookie model, a better headers model and a better call model. OkHttp makes canceling calls easy. OkHttp has carefully managed TLS defaults that are secure and widely compatible. Okhttp works with Retrofit, which is a brilliant API for REST. It also works with Okio, which is a great library for data streams. OkHttp is a small library with one small dependency (Okio) and is less code to learn. OkHttp is more widely deployed, with a billion Android 4.4+ devices using it internally.

like image 112
Al3xC Avatar answered Oct 02 '22 08:10

Al3xC