首页 > 解决方案 > 为什么 Android 的 HttpUrlConnection 不支持 HTTP/2?

问题描述

我刚刚发现Android推荐的http客户端HttpUrlConnection不支持HTTP/2。

是否有特定原因不在 Android 上使用 HTTP/2?

标签: androidnetworkinghttpurlconnectionokhttphttp2

解决方案


如果你想利用 HTTP/2,你可以使用 OkHttp:

https://github.com/square/okhttp

无论如何,它都优于 HttpUrlConnection。如果您正在做任何复杂的事情,例如从 Web API 获取复杂的 JSON 响应,我建议您使用 Retrofit:

https://square.github.io/retrofit/


推荐阅读