aboutsummaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-04-26 16:11:08 +0100
committerMatthew Wild <mwild1@gmail.com>2012-04-26 16:11:08 +0100
commita54e59650fb3aef98485286f3ffaf5cdf6140dab (patch)
tree237d371f67747e49a996cb0ace77bbc0b4f4a253 /net/http
parentb0b093e7264da1a620a2f4e9101e1b676ea1db0e (diff)
downloadprosody-a54e59650fb3aef98485286f3ffaf5cdf6140dab.tar.gz
prosody-a54e59650fb3aef98485286f3ffaf5cdf6140dab.zip
net.http.server: Fire http-error 400 if request fails sanity checks
Diffstat (limited to 'net/http')
-rw-r--r--net/http/server.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/net/http/server.lua b/net/http/server.lua
index deaa44cd..938e676d 100644
--- a/net/http/server.lua
+++ b/net/http/server.lua
@@ -170,10 +170,17 @@ function handle_request(conn, request, finish_cb)
};
conn._http_open_response = response;
+ local err;
if not request.headers.host then
+ err = "No 'Host' header";
+ elseif not request.path then
+ err = "Invalid path";
+ end
+
+ if err then
response.status_code = 400;
response.headers.content_type = "text/html";
- response:send(events.fire_event("http-error", { code = 400, message = "No 'Host' header" }));
+ response:send(events.fire_event("http-error", { code = 400, message = err }));
else
local host = request.headers.host;
if host then