fix asynchttpserver content-length header (#13846)
This commit is contained in:
parent
d23371fdd7
commit
6b9ffc7fad
1 changed files with 6 additions and 3 deletions
|
|
@ -99,9 +99,12 @@ proc respond*(req: Request, code: HttpCode, content: string,
|
||||||
|
|
||||||
if headers != nil:
|
if headers != nil:
|
||||||
msg.addHeaders(headers)
|
msg.addHeaders(headers)
|
||||||
msg.add("Content-Length: ")
|
|
||||||
# this particular way saves allocations:
|
if not headers.hasKey("Content-Length"):
|
||||||
msg.add content.len
|
msg.add("Content-Length: ")
|
||||||
|
# this particular way saves allocations:
|
||||||
|
msg.addInt content.len
|
||||||
|
|
||||||
msg.add "\c\L\c\L"
|
msg.add "\c\L\c\L"
|
||||||
msg.add(content)
|
msg.add(content)
|
||||||
result = req.client.send(msg)
|
result = req.client.send(msg)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue