lib/rack/deflater.rb in rack-1.3.10 vs lib/rack/deflater.rb in rack-1.4.0

- old
+ new

@@ -43,11 +43,10 @@ headers.delete('Content-Length') [status, headers, DeflateStream.new(body)] when "identity" [status, headers, body] when nil - body.close if body.respond_to?(:close) message = "An acceptable encoding for the requested resource #{request.fullpath} could not be found." [406, {"Content-Type" => "text/plain", "Content-Length" => message.length.to_s}, [message]] end end @@ -63,11 +62,10 @@ gzip.mtime = @mtime @body.each { |part| gzip.write(part) gzip.flush } - ensure @body.close if @body.respond_to?(:close) gzip.close @writer = nil end @@ -90,14 +88,12 @@ end def each deflater = ::Zlib::Deflate.new(*DEFLATE_ARGS) @body.each { |part| yield deflater.deflate(part, Zlib::SYNC_FLUSH) } + @body.close if @body.respond_to?(:close) yield deflater.finish nil - ensure - @body.close if @body.respond_to?(:close) - deflater.close end end end end