Changeset

11160:e9eeaefa09a7

Merge 0.11->trunk
author Matthew Wild <mwild1@gmail.com>
date Tue, 13 Oct 2020 11:59:40 +0100
parents 11158:3a72cb126d6c (current diff) 11159:de76f566159e (diff)
children 11161:f51ed2652602
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 21:29:20 2020 +0200
+++ b/net/http/server.lua	Tue Oct 13 11:59:40 2020 +0100
@@ -331,7 +331,10 @@
 function _M.send_response(response, body)
 	if response.finished then return; end
 	body = body or response.body or "";
-	response.headers.content_length = ("%d"):format(#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 = ("%d"):format(#body);
+	end
 	if response.is_head_request then
 		return _M.send_head_response(response)
 	end