Implement streamed async/sync downloadFile and deprecate old one.

This commit is contained in:
Dominik Picheta 2017-02-11 14:00:53 +01:00
commit f9f86899b5
3 changed files with 62 additions and 16 deletions

View file

@ -49,7 +49,8 @@ proc asyncTest() {.async.} =
echo("Downloaded ", progress, " of ", total)
echo("Current rate: ", speed div 1000, "kb/s")
client.onProgressChanged = onProgressChanged
discard await client.getContent("http://speedtest-ams2.digitalocean.com/100mb.test")
await client.downloadFile("http://speedtest-ams2.digitalocean.com/100mb.test",
"100mb.test")
client.close()
@ -96,7 +97,8 @@ proc syncTest() =
echo("Downloaded ", progress, " of ", total)
echo("Current rate: ", speed div 1000, "kb/s")
client.onProgressChanged = onProgressChanged
discard client.getContent("http://speedtest-ams2.digitalocean.com/100mb.test")
client.downloadFile("http://speedtest-ams2.digitalocean.com/100mb.test",
"100mb.test")
client.close()