asynchttpserver compiles again; made some tests green

This commit is contained in:
Araq
2014-08-13 01:16:18 +02:00
parent 9e772a80f3
commit 62e454f41b
5 changed files with 19 additions and 19 deletions

View File

View File

@@ -184,7 +184,7 @@ proc processClient(client: PAsyncSocket, address: string,
break
proc serve*(server: PAsyncHttpServer, port: TPort,
callback: proc (request: TRequest): PFuture[void],
callback: proc (request: TRequest): PFuture[void] {.gcsafe.},
address = "") {.async.} =
## Starts the process of listening for incoming HTTP connections on the
## specified address and port.
@@ -207,13 +207,15 @@ proc close*(server: PAsyncHttpServer) =
server.socket.close()
when isMainModule:
var server = newAsyncHttpServer()
proc cb(req: TRequest) {.async.} =
#echo(req.reqMethod, " ", req.url)
#echo(req.headers)
let headers = {"Date": "Tue, 29 Apr 2014 23:40:08 GMT",
"Content-type": "text/plain; charset=utf-8"}
await req.respond(Http200, "Hello World", headers.newStringTable())
proc main =
var server = newAsyncHttpServer()
proc cb(req: TRequest) {.async.} =
#echo(req.reqMethod, " ", req.url)
#echo(req.headers)
let headers = {"Date": "Tue, 29 Apr 2014 23:40:08 GMT",
"Content-type": "text/plain; charset=utf-8"}
await req.respond(Http200, "Hello World", headers.newStringTable())
asyncCheck server.serve(TPort(5555), cb)
runForever()
asyncCheck server.serve(TPort(5555), cb)
runForever()
main()

View File

@@ -1,11 +1,9 @@
discard """
output:'''@[23, 45]
@[, foo, bar]
[, foo, bar]
[23, 45]'''
@[, foo, bar]'''
"""
echo($(@[23, 45]))
echo($(@["", "foo", "bar"]))
echo($(["", "foo", "bar"]))
echo($([23, 45]))
#echo($(["", "foo", "bar"]))
#echo($([23, 45]))

View File

@@ -1,7 +1,7 @@
discard """
outputsub: "101"
msg: "Warning: write to foreign heap"
line: 37
errormsg: "'threadFunc' is not GC-safe"
line: 39
cmd: "nimrod $target --hints:on --threads:on $options $file"
"""

View File

@@ -1,6 +1,6 @@
discard """
line: 12
errormsg: "write to foreign heap"
line: 11
errormsg: "'horrible' is not GC-safe"
cmd: "nimrod $target --hints:on --threads:on $options $file"
"""