gpt4 book ai didi

java - Okhttp 或 HTTPClient : Which offers better functionality and more efficiency?

转载 作者:行者123 更新时间:2023-12-02 06:16:02 25 4
gpt4 key购买 nike

为了发出http请求,JAVA中有一些API可供选择,例如Apache HttpClient和Okhttp。 Apache HttpClient 已经成熟并且被广泛使用,而 Okhttp 似乎越来越流行(我不确定)。

我想知道的是,哪个更好,或者 Apache HttpClient 是否具有 Okhttp 没有的某些功能,或者反之亦然?大多数情况下,我谈论的是服务器端,谈论在 Android 应用程序中使用也非常好。

我希望能列出一些要点,这样我就可以弄清楚Apache HttpClient和Okhttp之间的区别。

引用:

URLConnection 和 HttpClient 之间存在问题: URLConnection or HTTPClient : Which offers better functionality and more efficiency?

最佳答案

我建议使用okhttp。原因如下: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.

关于java - Okhttp 或 HTTPClient : Which offers better functionality and more efficiency?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42392778/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com