mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-20 07:51:32 +00:00
fixes #22778 follow up https://github.com/nim-lang/Nim/pull/19835
This commit is contained in:
@@ -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 =
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user