fixes #22778 regression: contentLength implementation type mismatched (#22780)

fixes #22778
follow up https://github.com/nim-lang/Nim/pull/19835
This commit is contained in:
ringabout
2023-10-03 11:00:24 +08:00
committed by GitHub
parent 642ac0c1c3
commit 5d5c39e745
2 changed files with 2 additions and 1 deletions

View File

@@ -305,7 +305,7 @@ proc contentLength*(response: Response | AsyncResponse): int =
##
## A `ValueError` exception will be raised if the value is not an integer.
## If the Content-Length header is not set in the response, ContentLength is set to the value -1.
var contentLengthHeader = response.headers.getOrDefault("Content-Length", @["-1"])
var contentLengthHeader = response.headers.getOrDefault("Content-Length", HttpHeaderValues(@["-1"]))
result = contentLengthHeader.parseInt()
proc lastModified*(response: Response | AsyncResponse): DateTime =

View File

@@ -109,6 +109,7 @@ proc testCustomContentLength() {.async.} =
doAssert(body == "")
doAssert(response.headers.hasKey("Content-Length"))
doAssert(response.headers["Content-Length"] == "0")
doAssert contentLength(response) == 0 # bug #22778
runTest(handler, request, test)