1 # frozen_string_literal: true
3 require_relative 'constants'
4 require_relative 'body_proxy'
8 # Middleware tracks and cleans Tempfiles created throughout a request (i.e. Rack::Multipart)
9 # Ideas/strategy based on posts by Eric Wong and Charles Oliver Nutter
10 # https://groups.google.com/forum/#!searchin/rack-devel/temp/rack-devel/brK8eh-MByw/sw61oJJCGRMJ
17 env[RACK_TEMPFILES] ||= []
20 _, _, body = response = @app.call(env)
22 env[RACK_TEMPFILES]&.each(&:close!)
26 response[2] = BodyProxy.new(body) do
27 env[RACK_TEMPFILES]&.each(&:close!)