summary refs log tree commit diff stats
path: root/tests/ccgbugs/t9655.nim
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2021-01-11 11:02:32 -0600
committerGitHub <noreply@github.com>2021-01-11 18:02:32 +0100
commit5af13c5aceaedf211ff59113384bcb6a85c35c2b (patch)
treec4d022d8cd14e6113364d0281c5216ba624acac4 /tests/ccgbugs/t9655.nim
parent0c128259bb01cde8ed27430929b0a01c5ee7b88c (diff)
downloadNim-5af13c5aceaedf211ff59113384bcb6a85c35c2b.tar.gz
close #9655 add testcase (#16683)
Diffstat (limited to 'tests/ccgbugs/t9655.nim')
-rw-r--r--tests/ccgbugs/t9655.nim30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/ccgbugs/t9655.nim b/tests/ccgbugs/t9655.nim
new file mode 100644
index 000000000..29fb903a4
--- /dev/null
+++ b/tests/ccgbugs/t9655.nim
@@ -0,0 +1,30 @@
+discard """
+  action: "compile"
+"""
+
+import std/[asynchttpserver, asyncdispatch]
+import std/[strformat]
+
+proc main() =
+  let local = "123"
+
+  proc serveIndex(req: Request) {.async, gcsafe.} =
+    await req.respond(Http200, &"{local}")
+
+  proc serve404(req: Request) {.async, gcsafe.} =
+    echo req.url.path
+    await req.respond(Http404, "not found")
+
+  proc serve(req: Request) {.async, gcsafe.} =
+    let handler = case req.url.path:
+      of "/":
+        serveIndex
+      else:
+        serve404
+    await handler(req)
+
+  let server = newAsyncHttpServer()
+  waitFor server.serve(Port(8080), serve, address = "127.0.0.1")
+
+when isMainModule:
+  main()