diff options
author | Yuriy Glukhov <yglukhov@users.noreply.github.com> | 2021-01-14 09:53:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-14 08:53:21 +0100 |
commit | 4ae520711d72fa903cccf3e59754fd64f632d992 (patch) | |
tree | c3b607e6d13419b0ef8cb9a4ec36ec581fe23322 /tests | |
parent | 7f67c593c11ea4d2c5228eb983c8f1e2cafee0e4 (diff) | |
download | Nim-4ae520711d72fa903cccf3e59754fd64f632d992.tar.gz |
Fixes #16436 (#16695)
* Fixes #16436 * Comments addressed
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stdlib/thttpclient_standalone.nim | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/stdlib/thttpclient_standalone.nim b/tests/stdlib/thttpclient_standalone.nim new file mode 100644 index 000000000..44a88e91e --- /dev/null +++ b/tests/stdlib/thttpclient_standalone.nim @@ -0,0 +1,23 @@ +discard """ + cmd: "nim c --threads:on $file" +""" + +import asynchttpserver, httpclient, asyncdispatch + +block: # bug #16436 + proc startServer() {.async.} = + proc cb(req: Request) {.async.} = + let headers = { "Content-length": "15"} # Provide invalid content-length + await req.respond(Http200, "Hello World", headers.newHttpHeaders()) + + var server = newAsyncHttpServer() + await server.serve(Port(5555), cb) + + proc runClient() {.async.} = + let c = newAsyncHttpClient(headers = {"Connection": "close"}.newHttpHeaders) + let r = await c.getContent("http://127.0.0.1:5555") + doAssert false, "should fail earlier" + + asyncCheck startServer() + doAssertRaises(ProtocolError): + waitFor runClient() |