changeset 2207:c45ad4b7aaa3

mod_http_upload: Add additional debug logging
author Kim Alvefur <zash@zash.se>
date Sun, 12 Jun 2016 02:51:08 +0200
parents 724809023c92
children e654d6e1fb50
files mod_http_upload/mod_http_upload.lua
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_http_upload/mod_http_upload.lua	Fri Jun 10 14:58:39 2016 +0200
+++ b/mod_http_upload/mod_http_upload.lua	Sun Jun 12 02:51:08 2016 +0200
@@ -50,17 +50,20 @@
 	local request = stanza.tags[1];
 	-- local clients only
 	if origin.type ~= "c2s" then
+		module:log("debug", "Request for upload slot from a %s", origin.type);
 		origin.send(st.error_reply(stanza, "cancel", "not-authorized"));
 		return true;
 	end
 	-- validate
 	local filename = request:get_child_text("filename");
 	if not filename or filename:find("/") then
+		module:log("debug", "Filename %q not allowed", filename or "");
 		origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid filename"));
 		return true;
 	end
 	local filesize = tonumber(request:get_child_text("size"));
 	if not filesize then
+		module:log("debug", "Missing file size");
 		origin.send(st.error_reply(stanza, "modify", "bad-request", "Missing or invalid file size"));
 		return true;
 	elseif filesize > file_size_limit then
@@ -77,6 +80,7 @@
 	reply:tag("get"):text(url):up();
 	reply:tag("put"):text(url):up();
 	origin.send(reply);
+	origin.log("debug", "Given upload slot %q", random);
 	return true;
 end);
 
@@ -88,6 +92,7 @@
 	end
 	local random, filename = path:match("^([^/]+)/([^/]+)$");
 	if not random then
+		module:log("warn", "Invalid file path %q", path);
 		return 400;
 	end
 	if #event.request.body > file_size_limit then