diff options
author | Dominik Picheta <dominikpicheta@googlemail.com> | 2015-04-23 21:57:33 +0100 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@googlemail.com> | 2015-04-23 21:57:33 +0100 |
commit | 62e1b3e2e30906fb2176c018468138731d073a27 (patch) | |
tree | 1ffb50cbd2dbabc33976167aeae0407bcd86c05f | |
parent | 03cbf689a1f70e4b797ef0e7b14a2d93c4579f53 (diff) | |
download | Nim-62e1b3e2e30906fb2176c018468138731d073a27.tar.gz |
Some small cleanup.
-rw-r--r-- | lib/pure/asynchttpserver.nim | 11 | ||||
-rw-r--r-- | lib/pure/asyncnet.nim | 4 |
2 files changed, 7 insertions, 8 deletions
diff --git a/lib/pure/asynchttpserver.nim b/lib/pure/asynchttpserver.nim index f7a2b693f..279cedb5d 100644 --- a/lib/pure/asynchttpserver.nim +++ b/lib/pure/asynchttpserver.nim @@ -21,10 +21,9 @@ ## ## var server = newAsyncHttpServer() ## proc cb(req: Request) {.async.} = -## req.respond(Http200, "Hello World") +## await req.respond(Http200, "Hello World") ## -## asyncCheck server.serve(Port(8080), cb) -## runForever() +## waitFor server.serve(Port(8080), cb) import strtabs, asyncnet, asyncdispatch, parseutils, uri, strutils type @@ -38,7 +37,7 @@ type body*: string AsyncHttpServer* = ref object - socket*: AsyncSocket + socket: AsyncSocket reuseAddr: bool HttpCode* = enum @@ -112,9 +111,9 @@ proc sendHeaders*(req: Request, headers: StringTableRef): Future[void] = proc respond*(req: Request, code: HttpCode, content: string, headers: StringTableRef = nil): Future[void] = ## Responds to the request with the specified ``HttpCode``, headers and - ## content. This template returns a Future[void]. + ## content. ## - ## This template will **not** close the client socket. + ## This procedure will **not** close the client socket. var msg = "HTTP/1.1 " & $code & "\c\L" if headers != nil: diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim index 7d23ad4b7..b88fd80c0 100644 --- a/lib/pure/asyncnet.nim +++ b/lib/pure/asyncnet.nim @@ -69,13 +69,13 @@ type # TODO: I would prefer to just do: # AsyncSocket* {.borrow: `.`.} = distinct Socket. But that doesn't work. AsyncSocketDesc = object - fd*: SocketHandle + fd: SocketHandle closed: bool ## determines whether this socket has been closed case isBuffered: bool ## determines whether this socket is buffered. of true: buffer: array[0..BufferSize, char] currPos: int # current index in buffer - bufLen*: int # current length of buffer + bufLen: int # current length of buffer of false: nil case isSsl: bool of true: |