title: Android Https Status code -1
body: <p>I'm connecting to a web server from my android application via <code>HttpsUrlConnection</code> or <code>HttpUrlConnection</code> depending on settings. For now I didn't have any kind of problem, but yesterday I start getting <code>http/https status</code> response <code>-1</code>. There is no way the web server return me this even if there is some kind of error. The server which I'm connection to is designed to return <code>errorCode</code> and <code>errorString</code> when there is some kind of problem. Here is the code I'm using,but I don't think the problem is here.</p>
  
  <pre><code>    public void UseHttpConnection(String url, String charset, String query) {
      try {
          HttpURLConnection connection = (HttpURLConnection) new URL(url)
                  .openConnection();
          connection.setDoOutput(true);
          connection.setRequestMethod("POST");
          connection.setRequestProperty("Charset", charset);
          connection.setRequestProperty("Content-Type",
                  "application/x-www-form-urlencoded;charset=" + charset);
          OutputStream output = null;
          try {
              output = connection.getOutputStream();
              output.write(query.getBytes(charset));
          } catch (IOException e) {
              e.printStackTrace();
          } finally {
              if (output != null)
                  try {
                      output.close();
                  } catch (IOException logOrIgnore) {
                  }
          }
  
          int status = ((HttpURLConnection) connection).getResponseCode();
          Log.i("", "Status : " + status);
  
          for (Entry&lt;String, List&lt;String&gt;&gt; header : connection
                  .getHeaderFields().entrySet()) {
              Log.i("Headers",
                      "Headers : " + header.getKey() + "="
                              + header.getValue());
          }
  
          InputStream response = new BufferedInputStream(
                  connection.getInputStream());
  
          int bytesRead = -1;
          byte[] buffer = new byte[30 * 1024];
          while ((bytesRead = response.read(buffer)) &gt; 0) {
              byte[] buffer2 = new byte[bytesRead];
              System.arraycopy(buffer, 0, buffer2, 0, bytesRead);
              handleDataFromSync(buffer2);
          }
          connection.disconnect();
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>So my question is, what should <code>-1</code> stands for. Is it response for some kind of error or something else?</p>