diff options
author | Kim Alvefur <zash@zash.se> | 2014-11-09 20:32:33 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2014-11-09 20:32:33 +0100 |
commit | 3b5fa59a5496cd0d19e2a0dac067188d61d76c36 (patch) | |
tree | 00a4652d294babdf3be6f9add9a811a0e180a5d8 /plugins | |
parent | 763567fa0236b0b80e0271ed1d3325501b979ee1 (diff) | |
parent | 486335f3dbc84dacf253120f544f1d2ee026cf94 (diff) | |
download | prosody-3b5fa59a5496cd0d19e2a0dac067188d61d76c36.tar.gz prosody-3b5fa59a5496cd0d19e2a0dac067188d61d76c36.zip |
Merge 0.10->trunk
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_admin_telnet.lua | 3 | ||||
-rw-r--r-- | plugins/mod_http.lua | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index 55eb2e55..9185ac1b 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -27,6 +27,7 @@ local set, array = require "util.set", require "util.array"; local cert_verify_identity = require "util.x509".verify_identity; local envload = require "util.envload".envload; local envloadfile = require "util.envload".envloadfile; +local has_pposix, pposix = pcall(require, "util.pposix"); local commands = module:shared("commands") local def_env = module:shared("env"); @@ -322,7 +323,7 @@ local function human(kb) end function def_env.server:memory() - if not pposix.meminfo then + if not has_pposix or not pposix.meminfo then return true, "Lua is using "..collectgarbage("count"); end local mem, lua_mem = pposix.meminfo(), collectgarbage("count"); diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua index 49529ea2..8bda1cac 100644 --- a/plugins/mod_http.lua +++ b/plugins/mod_http.lua @@ -45,6 +45,11 @@ local function get_base_path(host_module, app_name, default_app_path) :gsub("%$(%w+)", { host = host_module.host }); end +local function redir_handler(event) + event.response.headers.location = event.request.path.."/"; + return 301; +end + local ports_by_scheme = { http = 80, https = 443, }; -- Helper to deduce a module's external URL @@ -99,6 +104,9 @@ function module.add_host(module) local path = event.request.path:sub(base_path_len); return _handler(event, path); end; + module:hook_object_event(server, event_name:sub(1, -3), redir_handler, -1); + elseif event_name:sub(-1, -1) == "/" then + module:hook_object_event(server, event_name:sub(1, -2), redir_handler, -1); end if not app_handlers[event_name] then app_handlers[event_name] = handler; |