Skip empty lines before status line

As recommended here: https://tools.ietf.org/html/rfc7230#section-3.5
This commit is contained in:
Dmitry Polienko 2016-10-28 17:34:07 +07:00
commit 860264a382

View file

@ -133,14 +133,21 @@ proc processClient(client: AsyncSocket, address: string,
assert client != nil assert client != nil
request.client = client request.client = client
# First line - GET /path HTTP/1.1 # We should skip empty lines before the request
lineFut.mget().setLen(0) # https://tools.ietf.org/html/rfc7230#section-3.5
lineFut.clean() while true:
await client.recvLineInto(lineFut) # TODO: Timeouts. lineFut.mget().setLen(0)
if lineFut.mget == "": lineFut.clean()
client.close() await client.recvLineInto(lineFut) # TODO: Timeouts.
return
if lineFut.mget == "":
client.close()
return
if lineFut.mget != "\c\L":
break
# First line - GET /path HTTP/1.1
var i = 0 var i = 0
for linePart in lineFut.mget.split(' '): for linePart in lineFut.mget.split(' '):
case i case i