Android 使用 HTTPS 时奇怪的 BufferedReader 行为
这就是场景。
我使用 HttpURLConnection 类执行 HTTP POST 来发布到“https://www.abc.com”的 url,但是这一行:
in = new BufferedReader(new InputStreamReader(
httpURLConnector.getInputStream()));
response = in.readLine();
随机给我一个空响应。但是,如果我从网址中删除“s”以变为“http://www.abc.com”,我将按预期返回所有响应,并且不会返回空值。奇怪的是,它可以在 Nexus 手机上使用 https,但不适用于 HTC Wildfire。有人可以启发我吗?谢谢!
This is the scenario.
I do a HTTP POST using the HttpURLConnection class to post to a url say "https://www.abc.com", but this line:
in = new BufferedReader(new InputStreamReader(
httpURLConnector.getInputStream()));
response = in.readLine();
randomly gives me a null response. But if I remove the 's' from the url to become "http://www.abc.com", I get back all responses as expected with no null returns. The weird thing is that it works on the Nexus phone for https but it does not work for the HTC Wildfire. Can someone enlighten me on this? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在尝试读取任何内容之前,您可能需要检查 HTTP 状态代码。从“HttpURLConnector”发布一些代码。
You might want to check the HTTP status code, before trying to read anything. Post some code from the `HttpURLConnector'.