changeset 13973:1746a6bd4644

Merge 13.0->trunk
author Kim Alvefur <zash@zash.se>
date Thu, 02 Oct 2025 21:08:15 +0200
parents 97d15552d364 (current diff) 67b8f2ee41ed (diff)
children eae7d0350a52
files plugins/mod_http_file_share.lua
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_http_file_share.lua	Wed Oct 01 17:39:20 2025 +0200
+++ b/plugins/mod_http_file_share.lua	Thu Oct 02 21:08:15 2025 +0200
@@ -68,7 +68,7 @@
 		code = 413;
 		type = "modify";
 		condition = "not-acceptable";
-		text = "File too large";
+		text = "File too large"; -- also used if file is too small
 		extra = {
 			tag = st.stanza("file-too-large", { xmlns = namespace }):tag("max-file-size"):text(tostring(file_size_limit));
 		};
@@ -295,6 +295,7 @@
 			return upload_errors.new("unauthz", { request = request });
 		end
 		if request.headers.content_length and tonumber(request.headers.content_length) ~= authed_upload_info.filesize then
+			module:log("debug", "Unexpected Content-Length %q, expected %s", request.headers.content_length, B(authed_upload_info.filesize));
 			return upload_errors.new("filesize", { request = request });
 			-- Note: We don't know the size if the upload is streamed in chunked encoding,
 			-- so we also check the final file size on completion.
@@ -353,6 +354,7 @@
 		local uploaded, err = errors.coerce(request.body_sink:close());
 		if final_size ~= upload_info.filesize then
 			-- Could be too short as well, but we say the same thing
+			module:log("debug", "Final file size is %s but expected %s (%s difference)", B(final_size), B(upload_info.filesize), B(upload_info.filesize - final_size));
 			uploaded, err = false, upload_errors.new("filesize", { request = request });
 		end
 		if uploaded then