On Sun, 11 Aug 2013 15:12:48 GMT, nazriel wrote:

(...)

if (last_read < BUFF_SIZE) 
{
    break;
}

(...)

This check should be removed, as it may very well trigger in the middle of the transfer. It's the number of bytes in the receive buffer of the socket and that may be just a few bytes for example if the client reads faster than the origin server writes.

You can also replace the whole while loop with the following, which will basically do exactly the same thing:

res.bodyWriter.write(r.bodyReader);

The issue with parallel requests is strange though. What is the exact exception/call stack which causes the 500 error? Can you maybe try to use a StopWatch or log messages to see where it hangs in each request handler?