Skip to content

Commit

Permalink
optimize json
Browse files Browse the repository at this point in the history
  • Loading branch information
bung87 committed May 28, 2023
1 parent babaa0f commit d00ed41
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/scorper/http/streamserver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,10 @@ proc serveStatic*(req: Request) {.async.} =
proc json*(req: ImpRequest): Future[JsonNode] {.async.} =
if req.parsedJson.isSome:
return req.parsedJson.unSafeGet
var str: string
var str = newString(req.contentLength)
result = newJNull()
try:
str = await req.reader.readLine(limit = req.contentLength.int)
await req.reader.readExactly(str[0].addr, req.contentLength.int)
except AsyncStreamIncompleteError:
await req.respStatus(Http400, ContentLengthMismatch)
req.parsedJson = some(result)
Expand Down

0 comments on commit d00ed41

Please sign in to comment.