Skip to content

Instantly share code, notes, and snippets.

@zacharycarter
Last active September 3, 2018 23:36
Show Gist options
  • Save zacharycarter/92c38941845c05b8b0479a6c4cedc11f to your computer and use it in GitHub Desktop.
Save zacharycarter/92c38941845c05b8b0479a6c4cedc11f to your computer and use it in GitHub Desktop.
import asyncdispatch, httpclient
var client = newAsyncHttpClient()
let fut = withTimeout(client.getContent("https://localhost:8080"), 2500)
discard waitFor fut
echo fut.failed
nim c -d:release -d:ssl http_test_server.nim
nim c -d:release -d:ssl http_test_client.nim
./http_test_server
./http_test_client
output:
false
import options, asyncdispatch
import httpbeast
proc onRequest(req: Request): Future[void] =
if req.httpMethod == some(HttpGet):
case req.path.get()
of "/":
req.send("Hello World")
else:
req.send(Http404)
run(onRequest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment