diff options
author | Bung <crc32@qq.com> | 2022-09-22 06:01:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-21 18:01:22 -0400 |
commit | de089d7fdb48a25069c3716ba00774b60c3da370 (patch) | |
tree | f3e71f2090853e20f2c68a0bf64bd84f42de2f07 /lib/pure/httpclient.nim | |
parent | 70c25c45d61926beca789fda0e57a10cbeef81e3 (diff) | |
download | Nim-de089d7fdb48a25069c3716ba00774b60c3da370.tar.gz |
contentLength default to -1 if not present (#19835)
* contentLength default to -1 if not present * `httpclient.contentLength` changelog
Diffstat (limited to 'lib/pure/httpclient.nim')
-rw-r--r-- | lib/pure/httpclient.nim | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index dcd1f87d6..405fadc2f 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -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. |