Skip to content

Instantly share code, notes, and snippets.

@enthus1ast
Created April 25, 2018 13:15
Show Gist options
  • Save enthus1ast/a052d8c4dbf487f0d9fb6f91ddf1dd77 to your computer and use it in GitHub Desktop.
Save enthus1ast/a052d8c4dbf487f0d9fb6f91ddf1dd77 to your computer and use it in GitHub Desktop.
import httpclient, asyncdispatch
var client = newAsyncHttpClient()
proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} =
echo("Downloaded ", progress, " of ", total)
echo("Current rate: ", speed div 1000, "kb/s")
client.onProgressChanged = onProgressChanged
echo waitFor client.getContent("http://speedtest-ams2.digitalocean.com/100mb.test")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment