title: java.io.IOException: unexpected end of stream on Connection in android
body: <p>I have web service URL, it working fine. It gives the JSON data. </p>
  
  <p>When I am using <code>HttpURLConnection</code> and <code>InputStream</code>, I am getting this error: </p>
  
  <pre><code>java.io.IOException: unexpected end of stream on
  Connection{comenius-api.sabacloud.com:443, proxy=DIRECT
  hostAddress=12.130.57.1
  cipherSuite=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 protocol=http/1.1}
  (recycle count=0)
  </code></pre>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>try {
      URL url = new URL("https://comenius-api.sabacloud.com/v1/people/username=" + username + ":(internalWorkHistory)?type=internal&amp;SabaCertificate=" + certificate);
  
      HttpURLConnection con = (HttpURLConnection) url.openConnection();
      InputStream ist = con.getInputStream();
      BufferedReader reader = new BufferedReader(new InputStreamReader(ist));
  
      while ((singleLine = reader.readLine()) != null) {
          data = data + singleLine;
          Log.e("Response", data);
      }
  
  } catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>How to fix this?</p>