On Mon, 12 Aug 2013 17:45:55 GMT, Sönke Ludwig wrote:

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);


I could swear I used it and I had issues with it.
No idea what happened back then but now it just works hah.

Everything seems to work now.
The only issue I have got is the fact, that when I set loglevel to trace, and client disconnects (for example stops download), app seems to still download file from remote server (I maybe wrong here. Got bunch of:

evbuffer_read 10592 bytes (fd 10)
 .. got 1448 bytes
yield
socket 10 read event!
resume
evbuffer_read 9144 bytes (fd 10)
 .. got 1448 bytes

And those appears after client connects/server starts fetching file

Shouldn't it stop downloading remote file after user disconnects in my scenario?
(

res.bodyWriter.write(r.bodyReader);

)

Thanks alot!