From 7f6dcc373f924b1a0a7dfa6739aa22545215c9db Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 28 Apr 2012 01:13:49 +0100 Subject: net.http.server: Try default_host if client sent no host anywhere, otherwise... fail. It's 2012. --- net/http/server.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/http/server.lua b/net/http/server.lua index eb30da78..8b91b4d3 100644 --- a/net/http/server.lua +++ b/net/http/server.lua @@ -174,15 +174,15 @@ function handle_request(conn, request, finish_cb) -- 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; - else + elseif host then err_code, err = 404, "Unknown host: "..host; + else + err_code, err = 400, "Missing or invalid 'Host' header"; end end -- cgit v1.2.3