Diff

net/http/server.lua @ 10951:f4215f8baa5d 0.11

net.http.server: Fix reporting of missing Host header The "Missing or invalid 'Host' header" case was dead code previously because `host` was always at least an empty string.
author Kim Alvefur <zash@zash.se>
date Tue, 23 Jun 2020 15:43:57 +0200
parent 10950:a23328c46389
child 10952:05d218aae3d1
child 11159:de76f566159e
line wrap: on
line diff
--- a/net/http/server.lua	Tue Jun 23 15:39:31 2020 +0200
+++ b/net/http/server.lua	Tue Jun 23 15:43:57 2020 +0200
@@ -207,7 +207,8 @@
 	};
 	conn._http_open_response = response;
 
-	local host = (request.headers.host or ""):gsub(":%d+$","");
+	local host = request.headers.host;
+	if host then host = host:gsub(":%d+$",""); end
 
 	-- Some sanity checking
 	local err_code, err;