diff options
author | supakeen <39536295+supakeen@users.noreply.github.com> | 2020-04-05 09:02:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-05 09:02:30 +0200 |
commit | 09ca19208f7c9aa52e71b50cf53cc369612e3fce (patch) | |
tree | 657e8b7acc6ea4c08838a21ef6a66618938b82a9 /lib | |
parent | 813ed358bfe7c282e9adc81bdd7f8a9ff2dc17b9 (diff) | |
download | Nim-09ca19208f7c9aa52e71b50cf53cc369612e3fce.tar.gz |
Add isNil check to custom Content-Length. (#13867) [backport:1.2]
Related to #13866.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/asynchttpserver.nim | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/pure/asynchttpserver.nim b/lib/pure/asynchttpserver.nim index a9ea4780f..7fbbf38ea 100644 --- a/lib/pure/asynchttpserver.nim +++ b/lib/pure/asynchttpserver.nim @@ -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 |