mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 01:14:41 +00:00
Skip empty lines before status line
As recommended here: https://tools.ietf.org/html/rfc7230#section-3.5
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user