mirror of
https://github.com/nim-lang/Nim.git
synced 2026-05-02 12:04:44 +00:00
contentLength default to -1 if not present (#19835)
* contentLength default to -1 if not present * `httpclient.contentLength` changelog
This commit is contained in:
@@ -274,9 +274,9 @@ proc contentLength*(response: Response | AsyncResponse): int =
|
||||
## This is effectively the value of the "Content-Length" header.
|
||||
##
|
||||
## A `ValueError` exception will be raised if the value is not an integer.
|
||||
var contentLengthHeader = response.headers.getOrDefault("Content-Length")
|
||||
## 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"])
|
||||
result = contentLengthHeader.parseInt()
|
||||
doAssert(result >= 0 and result <= high(int32))
|
||||
|
||||
proc lastModified*(response: Response | AsyncResponse): DateTime =
|
||||
## Retrieves the specified response's last modified time.
|
||||
|
||||
Reference in New Issue
Block a user