From f3b542a5bb40f8399ff1438569192bf531b422e9 Mon Sep 17 00:00:00 2001 From: Christoffer Sawicki Date: Sat, 5 Jul 2008 02:13:17 +0200 Subject: deflater.rb - Move out the Zlib::Deflate constructor arguments to a constant --- lib/rack/deflater.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/rack/deflater.rb b/lib/rack/deflater.rb index d4f4e137..047940ff 100644 --- a/lib/rack/deflater.rb +++ b/lib/rack/deflater.rb @@ -42,14 +42,17 @@ class Deflater return io.string end + DEFLATE_ARGS = [ + Zlib::DEFAULT_COMPRESSION, + # drop the zlib header which causes both Safari and IE to choke + -Zlib::MAX_WBITS, + Zlib::DEF_MEM_LEVEL, + Zlib::DEFAULT_STRATEGY + ] + # Loosely based on Mongrel's Deflate handler def self.deflate(body) - deflater = Zlib::Deflate.new( - Zlib::DEFAULT_COMPRESSION, - # drop the zlib header which causes both Safari and IE to choke - -Zlib::MAX_WBITS, - Zlib::DEF_MEM_LEVEL, - Zlib::DEFAULT_STRATEGY) + deflater = Zlib::Deflate.new(*DEFLATE_ARGS) # TODO: Add streaming # TODO: Consider all part types -- cgit v1.2.1