嗨在我的Android应用程序我使用HttpUrlconnection的Web服务。因此,对于任何具有响应401的Web资源请求,它不会给出任何标题字段或响应代码。并且它显示内容长度为-1。它引发异常java.io.IOException: Received authentication challenge is null
。现在我的问题是如何检查这些条件的响应代码。需要帮忙。我检查在休息客户的请求,但我发现,我的回应与包头响应码来正确地与401等领域也无法获得响应代码为401与HTTP网址连接
我的要求看起来像
String urlString ="http://WWW.ABC.com";
URL url = new URL(urlString);
login_urlConnection = (HttpURLConnection) url.openConnection();
login_urlConnection.setRequestMethod("GET");
int statusCode = login_urlConnection.getResponseCode() // Here I am getting exception I want this status code to check authentication failure
如何来解决这个问题。需要帮忙。谢谢。
我做了与HttpClient相同的调用,然后我能够得到响应代码,那么为什么不用HttpUrlConnection。我做错了什么需要帮助。
http://android-spirit.blogspot.in/2013/07/cosume-phpget-method-webservice-in.html – Nirmal