Changeset

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
parents 10950:a23328c46389
children 10952:05d218aae3d1 10994:e2ce067bb59a
files net/http/server.lua
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
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;