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.10 lib/rack/tempfile_reaper.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rack-2.2.9/lib/rack/tempfile_reaper.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rack-2.2.7/lib/rack/tempfile_reaper.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rack-2.2.7/lib/rack/tempfile_reaper.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rack-2.2.7/lib/rack/tempfile_reaper.rb
rack-2.2.9 lib/rack/tempfile_reaper.rb
rack-2.2.8.1 lib/rack/tempfile_reaper.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rack-2.2.7/lib/rack/tempfile_reaper.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/tempfile_reaper.rb
rack-2.2.8 lib/rack/tempfile_reaper.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rack-2.2.7/lib/rack/tempfile_reaper.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/tempfile_reaper.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/tempfile_reaper.rb
rack-2.2.7 lib/rack/tempfile_reaper.rb
rack-2.2.6.4 lib/rack/tempfile_reaper.rb
rack-2.2.6.3 lib/rack/tempfile_reaper.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/tempfile_reaper.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/tempfile_reaper.rb