tus/tusd — pull request #18 by doggy (2013-12-12 10:00:44+00:00)
Title: fix bug: a broken http connection will cause io.Copy() stuck and file’s ...

...offset will not be updated

To debug on this bug, I add some logs on handler.go to warning me while a file upload(method: PATCH) was began.
The result shows me that io.Copy() stucks on a connection which is unexpected interruption.

So I add a timeout on data read/write to http server.

partial logs with comment:

1st http connect broken:
>patchFile enter
WriteFileChunk will call io.Copy(8f300b5a06e1337363690a9a141c1659, 0)
WriteFileChunk return io.Copy n=3828828
setOffset enter, offset=3828828
WriteFileChunk end of io.Copy
error h.store.WriteFileChunk
2013/12/12 07:29:17.374662 error: read tcp 192.168.1.106:54234: i/o timeout

2nd http connect broken:
>patchFile enter
WriteFileChunk will call io.Copy(8f300b5a06e1337363690a9a141c1659, 3828828)
WriteFileChunk return io.Copy n=4365849
setOffset enter, offset=8194677
WriteFileChunk end of io.Copy
error h.store.WriteFileChunk
2013/12/12 07:30:29.098481 error: read tcp 192.168.1.106:54751: i/o timeout

3rd http connect and whole file uploaded:
>patchFile enter
WriteFileChunk will call io.Copy(8f300b5a06e1337363690a9a141c1659, 8194677)
WriteFileChunk return io.Copy n=12396883
setOffset enter, offset=20591560
WriteFileChunk end of io.Copy
return patchFile