see Content-Length HTTP header, and when $file().size == content-length, then file downloaded.