Software /
code /
prosody
Changeset
11159:de76f566159e 0.11
net.http.server: Don't send Content-Length on 1xx/204 responses, per RFC (fixes #1596)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 13 Oct 2020 11:55:28 +0100 |
parents | 11157:413bd21ba449 |
children | 11160:e9eeaefa09a7 11162:ee399a0522cc |
files | net/http/server.lua |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/net/http/server.lua Mon Oct 12 20:21:18 2020 +0200 +++ b/net/http/server.lua Tue Oct 13 11:55:28 2020 +0100 @@ -295,7 +295,10 @@ function _M.send_response(response, body) if response.finished then return; end body = body or response.body or ""; - response.headers.content_length = #body; + -- Per RFC 7230, informational (1xx) and 204 (no content) should have no c-l header + if response.status_code > 199 and response.status_code ~= 204 then + response.headers.content_length = #body; + end local output = prepare_header(response); t_insert(output, body); response.conn:write(t_concat(output));