Changeset

4740:bd9c8bc8036f

net.http.server: Try default_host if client sent no host anywhere, otherwise... fail. It's 2012.
author Matthew Wild <mwild1@gmail.com>
date Sat, 28 Apr 2012 01:13:49 +0100
parents 4739:f1d32a0dc057
children 4741:0653476ac3a3
files net/http/server.lua
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/net/http/server.lua	Sat Apr 28 00:51:36 2012 +0100
+++ b/net/http/server.lua	Sat Apr 28 01:13:49 2012 +0100
@@ -174,15 +174,15 @@
 
 	-- Some sanity checking
 	local err_code, err;
-	if not host then
-		err_code, err = 400, "Missing or invalid 'Host' header";
-	elseif not request.path then
+	if not request.path then
 		err_code, err = 400, "Invalid path";
 	elseif not hosts[host] then
 		if hosts[default_host] then
 			host = default_host;
+		elseif host then
+			err_code, err = 404, "Unknown host: "..host;
 		else
-			err_code, err = 404, "Unknown host: "..host;
+			err_code, err = 400, "Missing or invalid 'Host' header";
 		end
 	end