asynchttpserver compiles again; made some tests green

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

View file

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

View file

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

View file

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