diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-04-26 16:11:08 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-04-26 16:11:08 +0100 |
commit | 9db4ba52f9cbab52721ed819e4e81f3cbd62d106 (patch) | |
tree | 237d371f67747e49a996cb0ace77bbc0b4f4a253 /net/http/server.lua | |
parent | 91393747a3aa127e13ba07bc71340c59b708430d (diff) | |
download | prosody-9db4ba52f9cbab52721ed819e4e81f3cbd62d106.tar.gz prosody-9db4ba52f9cbab52721ed819e4e81f3cbd62d106.zip |
net.http.server: Fire http-error 400 if request fails sanity checks
Diffstat (limited to 'net/http/server.lua')
-rw-r--r-- | net/http/server.lua | 9 |
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 |