mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-26 00:21:42 +00:00
catch Defect in asynchttpserver for bad http request (#25820)
https://github.com/nim-lang/Nim/issues/25819 --------- Co-authored-by: Andreas Rumpf <araq4k@proton.me>
This commit is contained in:
@@ -152,9 +152,11 @@ proc parseProtocol(protocol: string): tuple[orig: string, major, minor: int] =
|
||||
raise newException(ValueError, "Invalid request protocol. Got: " &
|
||||
protocol)
|
||||
result.orig = protocol
|
||||
i.inc protocol.parseSaturatedNatural(result.major, i)
|
||||
if i < protocol.len: inc i # Skip .
|
||||
i.inc protocol.parseSaturatedNatural(result.minor, i)
|
||||
var n = protocol.parseSaturatedNatural(result.major, i)
|
||||
i.inc n
|
||||
if i < protocol.len and protocol[i] == '.':
|
||||
inc i
|
||||
n = protocol.parseSaturatedNatural(result.minor, i)
|
||||
|
||||
proc sendStatus(client: AsyncSocket, status: string): Future[void] =
|
||||
client.send("HTTP/1.1 " & status & "\c\L\c\L")
|
||||
|
||||
Reference in New Issue
Block a user