Sha256: cf775f9296d3752b2dc9185f8147f5411a4d7edd8161c0a1eebba4b0bbae47e5

Contents?: true

Size: 661 Bytes

Versions: 62

Compression:

Stored size: 661 Bytes

Contents

# frozen_string_literal: true

module Rack

  # Middleware tracks and cleans Tempfiles created throughout a request (i.e. Rack::Multipart)
  # Ideas/strategy based on posts by Eric Wong and Charles Oliver Nutter
  # https://groups.google.com/forum/#!searchin/rack-devel/temp/rack-devel/brK8eh-MByw/sw61oJJCGRMJ
  class TempfileReaper
    def initialize(app)
      @app = app
    end

    def call(env)
      env[RACK_TEMPFILES] ||= []
      status, headers, body = @app.call(env)
      body_proxy = BodyProxy.new(body) do
        env[RACK_TEMPFILES].each(&:close!) unless env[RACK_TEMPFILES].nil?
      end
      [status, headers, body_proxy]
    end
  end
end

Version data entries

62 entries across 47 versions & 14 rubygems

Version Path
rack-2.2.6.2 lib/rack/tempfile_reaper.rb
rack-2.2.6.1 lib/rack/tempfile_reaper.rb
rack-2.2.6 lib/rack/tempfile_reaper.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/tempfile_reaper.rb
rack-2.2.5 lib/rack/tempfile_reaper.rb
diy_rails-0.1.0 vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/tempfile_reaper.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/rack-2.2.4/lib/rack/tempfile_reaper.rb
rack-2.2.4 lib/rack/tempfile_reaper.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/rack-2.2.3.1/lib/rack/tempfile_reaper.rb
rack-2.2.3.1 lib/rack/tempfile_reaper.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb