Async httpclient should now work. Changed recv behaviour.

asyncdispatch.recv no longer guarantees that it will read ALL the data
requested. The underlying WinAPI function doesn't guarantee this and it
already wasn't guaranteed anyway since the socket could disconnect
mid-transmission.
This commit is contained in:
Dominik Picheta 2014-04-03 20:02:42 +01:00
commit 4399895d2e
3 changed files with 71 additions and 35 deletions

View file

@ -116,7 +116,8 @@ proc recvLine*(socket: PAsyncSocket): PFuture[string] {.async.} =
if c == "\r":
c = await recv(socket, 1, MSG_PEEK)
if c.len > 0 and c == "\L":
discard await recv(socket, 1)
let dummy = await recv(socket, 1)
assert dummy == "\L"
addNLIfEmpty()
return
elif c == "\L":
@ -148,7 +149,7 @@ when isMainModule:
TestCases = enum
HighClient, LowClient, LowServer
const test = LowServer
const test = HighClient
when test == HighClient:
proc main() {.async.} =