mod_http: Add way to signal that a module supports streaming uploads
authorKim Alvefur <zash@zash.se>
Sat, 01 Aug 2020 18:41:30 +0200
changeset 11026 3e5bc34be734
parent 11025 9673c95895fb
child 11027 a59b37b03eca
mod_http: Add way to signal that a module supports streaming uploads Fixes #726 API: module:provides("http", { streaming_uploads = true; route = { PUT = function (event) event.request.body_sink = io.tmpfile(); return true; end } })
plugins/mod_http.lua
--- a/plugins/mod_http.lua	Sat Aug 01 18:41:23 2020 +0200
+++ b/plugins/mod_http.lua	Sat Aug 01 18:41:30 2020 +0200
@@ -138,6 +138,8 @@
 			return "";
 		end
 
+		local streaming = event.item.streaming_uploads;
+
 		for key, handler in pairs(event.item.route or {}) do
 			local event_name = get_http_event(host, app_path, key);
 			if event_name then
@@ -160,7 +162,7 @@
 				elseif event_name:sub(-1, -1) == "/" then
 					module:hook_object_event(server, event_name:sub(1, -2), redir_handler, -1);
 				end
-				do
+				if not streaming then
 					-- COMPAT Modules not compatible with streaming uploads behave as before.
 					local _handler = handler;
 					function handler(event) -- luacheck: ignore 432/event