为什么Android的HttpUrlConnection不支持HTTP/2? [英] Why HTTP/2 is not supported by Android's HttpUrlConnection?
本文介绍了为什么Android的HttpUrlConnection不支持HTTP/2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚发现Android推荐的http客户端HttpUrlConnection
不支持HTTP/2.
I just found out that Android's recommended http client HttpUrlConnection
doesn't support HTTP/2.
是否有特定原因不在Android上使用HTTP/2?
Is there a specific reason not to use HTTP/2 on Android?
推荐答案
如果要利用HTTP/2,可以使用OkHttp:
You can use OkHttp if you want to take advantage of HTTP/2:
https://github.com/square/okhttp
无论如何,它都优于HttpUrlConnection.如果您要做的一切都很复杂,例如从Web API获取复杂的JSON响应,我建议使用Retrofit:
It's superior to HttpUrlConnection anyway. If you're doing anything at all complicated, like getting complex JSON responses from a web API, I'd recommend Retrofit:
https://square.github.io/retrofit/
这篇关于为什么Android的HttpUrlConnection不支持HTTP/2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文