I'm really not sure about this, but I found something while debugging httpserver with the browsers. Maybe someone could test this and confirm it or refute me.
In handling of http persistent connections (header: connection != "close") every client need to decide when server finishes the request.
The criterion for this is the last chunk after the body. if it doesn't come, then the browser client decides to open a new connection.
See: https://en.wikipedia.org/wiki/HTTP_persistent_connection https://en.wikipedia.org/wiki/Chunked_transfer_encoding
I think the solution is to inject in Nim/lib/pure/asynchttpserver.nim line 348:
# send last chunk bit according to:
# https://en.wikipedia.org/wiki/HTTP_persistent_connection
# https://en.wikipedia.org/wiki/Chunked_transfer_encoding
await request.client.send("\0\c\L\c\L")