title: HttpURLConnection responsecode is randomly -1
body: <p>Hi I'm using following code to establish a url connection. But randomly I get the responseCode -1 (which is the default value of responseCode):    </p>
  
  <pre><code>  try {
          URL url = new URL(urlString);
  
          HttpURLConnection httpconn = (HttpURLConnection) url.openConnection();
  
          if (httpconn.getResponseCode() == HttpURLConnection.HTTP_OK) {
              handleData(new DataInputStream(httpconn.getInputStream()), requestCode);
          } else {
              Log.e(TAG, "HttpConnection not OK: " + httpconn.getResponseCode());
              ActivityHelper.httpError(this);
          }
          httpconn.disconnect();
      } catch (Exception e) {
          Log.e(TAG, "handleHttpConnection", e);
          ActivityHelper.httpError(this);
      }
  </code></pre>
  
  <p>Am I doing something wrong? Because it works perfectly in estimated 9 of 10 attempts.</p>