Speed up asynchttpserver significantly using all the previous changes

- Export socket field of AsyncHttpServer and addHeaders proc for templates

- Make respond a template instead of proc because of how often it's called.
  This means no more "await" when invoking it.

- Optimize respond template with special case for empty headers and
  Content-Length entry

- newRequest doesn't allocate a hostname and body anymore because they're
  copied in later

- Major changes to processClient to prevent allocations and copies
This commit is contained in:
def 2015-03-02 03:08:17 +01:00
commit 477b3594eb
2 changed files with 53 additions and 47 deletions

View file

@ -200,7 +200,7 @@ template readInto*(buf: cstring, size: int, socket: AsyncSocket,
res = recvIntoFut.read()
res
template readIntoBuf(socket: AsyncSocket,
template readIntoBuf*(socket: AsyncSocket,
flags: set[SocketFlag]): int =
var size = readInto(addr socket.buffer[0], BufferSize, socket, flags)
socket.currPos = 0