hi guys.....
I am a software developer and facing problem in getting the response code from http connection. It works fine when connection is achieved successfully but doesnt work when connected is not achieved. My code is as under.
url = new URL("http://www.google.co.in/");
URLConnection conn = url.openConnection();
httpconn= (HttpURLConnection)conn;
responseCode = httpconn.getResponseCode() ;
if(responseCode == HttpURLConnection.HTTP_OK)
{
Log.i("coming","200 pass");
httpconn.disconnect();
}
else
{
Log.i("coming","200 fail");
}
sleep(15000);
this code works well whee the response code is 200 but it never gives the response code 400 which it should give when not connected.
I am a software developer and facing problem in getting the response code from http connection. It works fine when connection is achieved successfully but doesnt work when connected is not achieved. My code is as under.
url = new URL("http://www.google.co.in/");
URLConnection conn = url.openConnection();
httpconn= (HttpURLConnection)conn;
responseCode = httpconn.getResponseCode() ;
if(responseCode == HttpURLConnection.HTTP_OK)
{
Log.i("coming","200 pass");
httpconn.disconnect();
}
else
{
Log.i("coming","200 fail");
}
sleep(15000);
this code works well whee the response code is 200 but it never gives the response code 400 which it should give when not connected.