getting response code from HttpURLConnection in android

牧云@^-^@ 提交于 2019-12-12 08:12:42

问题


i am establishing connection with the server and its working fine. But there are times when i try to get the response code (when server is throwing back 401, 403, 404) i am getting IO Exception. I am handling everything based on the response code. So when it throws IO exception on

http.getResponseCode()

i am not able to read the response code. Please suggest a solution for this.


回答1:


Prior to android 2.3 HttpUrlConnection has few issues. Its better to use Defaulthttpclient api. Seems your issue is similar to this.



来源:https://stackoverflow.com/questions/8849675/getting-response-code-from-httpurlconnection-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!