Skip to content

Instantly share code, notes, and snippets.

@zporter
Created June 15, 2012 14:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zporter/2936818 to your computer and use it in GitHub Desktop.
Save zporter/2936818 to your computer and use it in GitHub Desktop.
Fixes deadlock issue on Rack::Deflater
require 'rack/deflater'
module Rack
class Deflater
class GzipStream
def each(&block)
@writer = block
gzip =::Zlib::GzipWriter.new(self)
gzip.mtime = @mtime
@body.each { |part|
gzip.write(part)
gzip.flush
}
ensure
@body.close if @body.respond_to?(:close)
gzip.close if gzip && !gzip.closed?
@writer = nil
end
end
end
end
@elijahmurray
Copy link

Where does this go in my app?

@jonathan-mui
Copy link

jonathan-mui commented Mar 3, 2017

It goes in config/initializers/rack_deflater.rb rack/rack#349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment