[trac499] Correct problem with receiving large responses
The TCP handling reads into an intermediate staging buffer. The problem was that this buffer wasn't being emptied between multiple reads, only after the last one. If the total amount of data received was more than the staging buffer size, the code failed attempting to write beyond the buffer end. This fix empties the staging buffer after (more or less) every read from the network.
Showing with 454 additions and 311 deletions