Add isNil check to custom Content-Length. (#13867) [backport:1.2]
Related to #13866.
This commit is contained in:
parent
813ed358bf
commit
09ca19208f
1 changed files with 3 additions and 2 deletions
|
|
@ -100,7 +100,8 @@ 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue