bug收集

BUG - HttpURLConnectionImpl cann

2018-11-28  本文已影响0人  Candy有雪吃

问题描述如下:

之所以会出现那样的异常就在于下面这段代码的错误

URL url = new URL(urlString);
HttpsURLConnection connection= (HttpsURLConnection) url.openConnection();

我请求的图片的网址 开头是Http://,而却用HttpsURLConnection类型来指定网络连接的类型,肯定会抛出异常。。。

问题原因:你的urlString必须以这种形式开头:“http://” 而不是“https://” 这样你才能匹配HttpURLConnection.

解决办法:将HttpsURLConnection改为HttpURLConnection即可;

解释:

SSL(Secure Sockets Layer 安全套接层)

HTTPS(Secure Hypertext Transfer Protocol)安全超文本传输协议

这两者是相互对应的。

上一篇 下一篇

猜你喜欢

热点阅读