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
parent 0f3419685f
commit 860264a382

View File

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