Skip to content

Commit 5d5c39e

Browse files
authored
fixes nim-lang#22778 regression: contentLength implementation type mismatched (nim-lang#22780)
fixes nim-lang#22778 follow up nim-lang#19835
1 parent 642ac0c commit 5d5c39e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/pure/httpclient.nim

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

311311
proc lastModified*(response: Response | AsyncResponse): DateTime =

tests/stdlib/tasynchttpserver.nim

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ proc testCustomContentLength() {.async.} =
109109
doAssert(body == "")
110110
doAssert(response.headers.hasKey("Content-Length"))
111111
doAssert(response.headers["Content-Length"] == "0")
112+
doAssert contentLength(response) == 0 # bug #22778
112113

113114
runTest(handler, request, test)
114115

0 commit comments

Comments
 (0)