Hoverbear/rust-rosetta — pull request #207 by pfalabella (2014-08-22 16:01:46+00:00)
Title: webserver dropping connection (fixes #206?)

Now it works for me, but please check that it does for you too, because I'm not 100% sure what I've done here.. :)

The first thing I tried is to add a close_write(), because the error is saying that the server dropped the connection abruptly when done transmitting instead of sending teh expected "I'm done" signal. See http://stackoverflow.com/questions/1434451/what-does-connection-reset-by-peer-mean for reference.

This mitigated the issue for me but did not fix it (instead of giving me the error almost every time, I was getting it about 50% of the times).

The second ingredient that apparently fixed it (as in "it doesn't happen any longer for me....") is moving the println! out of handle_client(). I'm not sure why this helped... The reason I tried is that I suspected that writing to two different Writers (the stream and stdout) from within the same spawned task could create strange results in case of failure.