美文网首页bug收集
BUG - HttpURLConnectionImpl cann

BUG - HttpURLConnectionImpl cann

作者: Candy有雪吃 | 来源:发表于2018-11-28 11:27 被阅读0次

    问题描述如下:

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

    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)安全超文本传输协议

    这两者是相互对应的。

    相关文章

      网友评论

        本文标题:BUG - HttpURLConnectionImpl cann

        本文链接:https://www.haomeiwen.com/subject/hrdaqqtx.html