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:
|
||||
msg.addHeaders(headers)
|
||||
msg.add("Content-Length: ")
|
||||
# this particular way saves allocations:
|
||||
msg.add content.len
|
||||
|
||||
if not headers.hasKey("Content-Length"):
|
||||
msg.add("Content-Length: ")
|
||||
# this particular way saves allocations:
|
||||
msg.addInt content.len
|
||||
|
||||
msg.add "\c\L\c\L"
|
||||
msg.add(content)
|
||||
result = req.client.send(msg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue