protected void checkResponseCode(URLConnection conn) throws Exception {
  if (conn instanceof HttpURLConnection) {
    HttpURLConnection httpConn=(HttpURLConnection)conn;
    int responseCode=httpConn.getResponseCode();
    if (responseCode == -1) {
      Log.w(LOG,"Empty response code: " + responseCode + " "+ httpConn.getResponseMessage());
    }
 else     if (responseCode < 200 || responseCode > 299) {
      Log.e(LOG,"Error response code: " + responseCode + " "+ httpConn.getResponseMessage());
      throw new IOException("Error response: " + responseCode + " "+ httpConn.getResponseMessage());
    }
 else {
      Log.d(LOG,"Response: " + responseCode + " "+ httpConn.getResponseMessage());
    }
  }
}

protected void checkResponseCode ( URLConnection conn ) throws Exception { if ( conn instanceof HttpURLConnection ) { HttpURLConnection httpConn = ( HttpURLConnection ) conn ; int responseCode = httpConn . getResponseCode ( ) ; if ( responseCode == - 1 ) { Log . w ( LOG , "Empty response code: " + responseCode + " " + httpConn . getResponseMessage ( ) ) ; } else if ( responseCode < 200 || responseCode > 299 ) { Log . e ( LOG , "Error response code: " + responseCode + " " + httpConn . getResponseMessage ( ) ) ; throw new IOException ( "Error response: " + responseCode + " " + httpConn . getResponseMessage ( ) ) ; } else { Log . d ( LOG , "Response: " + responseCode + " " + httpConn . getResponseMessage ( ) ) ; } } }
checks the response code . actually for httpurlconnection it throws an exception when the response code is not between 200 and 299 .
