aboutsummaryrefslogtreecommitdiffstats
path: root/net/http/server.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2020-10-13 11:55:28 +0100
committerMatthew Wild <mwild1@gmail.com>2020-10-13 11:55:28 +0100
commit3aa0f12f41b37d30556a7a0e55bde4ffde54d029 (patch)
treea844c33bd3ce085a41cbb725f170183b6656c912 /net/http/server.lua
parentee30af806d46b33d748d9df50caf3cb508746720 (diff)
downloadprosody-3aa0f12f41b37d30556a7a0e55bde4ffde54d029.tar.gz
prosody-3aa0f12f41b37d30556a7a0e55bde4ffde54d029.zip
net.http.server: Don't send Content-Length on 1xx/204 responses, per RFC (fixes #1596)
Diffstat (limited to 'net/http/server.lua')
-rw-r--r--net/http/server.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/http/server.lua b/net/http/server.lua
index 18704962..3873bbe0 100644
--- a/net/http/server.lua
+++ b/net/http/server.lua
@@ -295,7 +295,10 @@ _M.prepare_header = prepare_header;
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));