InputStream returns -1 before end of file
<p>I'm streaming a file from a server and then streaming it back out to a socket (basically a stream proxy).  This is being used to buffer a song.  So once the buffer is full, no more data is read from the socket until the buffer empties out.  However, once more data is read, the InputStream will read X more bytes, then suddenly return a -1 signaling the end of the file, when it is not.  Is there a timeout that is happening?</p>

<p>Here's some example code:</p>

<pre><code>  InputStream data = realResponse.getEntity().getContent();

  ...some code...

  int totalBytes = 0;
  int count = 0;
  // Start streaming content.
  byte[] buff = new byte[1024 * 50];
  while (isRunning &amp;&amp; (readBytes = data.read(buff, 0, buff.length)) != -1) {
    totalBytes += readBytes;

    Log(count + ": buffer:" + buff + " readBytes:" + readBytes + " total:" + totalBytes);
    client.getOutputStream().write(buff, 0, readBytes);
    Log("Finished write");
    count++;          

  }
</code></pre>

<p>An example of the log would look like:</p>

<pre><code>0: buffer:B@45030a50 readBytes: 16164 total: 16164
1: buffer:B@45030a50 readBytes: 16384 total: 32548
...
100: buffer:B@45030a50 readBytes: 16384 total: 1654564
&lt;a long pause here&gt;
100: buffer:B@45030a50 readBytes: 16384 total: 1670948
100: buffer:B@45030a50 readBytes: 16384 total: 1687332
-1 Received
</code></pre>

<p>Any help or suggestions are appreciate</p>
