mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-02 03:02:31 +00:00
Add isNil check to custom Content-Length. (#13867) [backport:1.2]
Related to #13866.
This commit is contained in:
@@ -99,8 +99,9 @@ proc respond*(req: Request, code: HttpCode, content: string,
|
||||
|
||||
if headers != nil:
|
||||
msg.addHeaders(headers)
|
||||
|
||||
if not headers.hasKey("Content-Length"):
|
||||
|
||||
# If the headers did not contain a Content-Length use our own
|
||||
if headers.isNil() or not headers.hasKey("Content-Length"):
|
||||
msg.add("Content-Length: ")
|
||||
# this particular way saves allocations:
|
||||
msg.addInt content.len
|
||||
|
||||
Reference in New Issue
Block a user