Software /
code /
prosody
Comparison
net/http/server.lua @ 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 |
parent | 4739:f1d32a0dc057 |
child | 4771:31a40da59308 |
comparison
equal
deleted
inserted
replaced
4739:f1d32a0dc057 | 4740:bd9c8bc8036f |
---|---|
172 | 172 |
173 local host = (request.headers.host or ""):match("[^:]+"); | 173 local host = (request.headers.host or ""):match("[^:]+"); |
174 | 174 |
175 -- Some sanity checking | 175 -- Some sanity checking |
176 local err_code, err; | 176 local err_code, err; |
177 if not host then | 177 if not request.path then |
178 err_code, err = 400, "Missing or invalid 'Host' header"; | |
179 elseif not request.path then | |
180 err_code, err = 400, "Invalid path"; | 178 err_code, err = 400, "Invalid path"; |
181 elseif not hosts[host] then | 179 elseif not hosts[host] then |
182 if hosts[default_host] then | 180 if hosts[default_host] then |
183 host = default_host; | 181 host = default_host; |
182 elseif host then | |
183 err_code, err = 404, "Unknown host: "..host; | |
184 else | 184 else |
185 err_code, err = 404, "Unknown host: "..host; | 185 err_code, err = 400, "Missing or invalid 'Host' header"; |
186 end | 186 end |
187 end | 187 end |
188 | 188 |
189 if err then | 189 if err then |
190 response.status_code = err_code; | 190 response.status_code = err_code; |