Skip to content
Browse files

deflater.rb - Move out the Zlib::Deflate constructor arguments to a c…

…onstant
  • Loading branch information...
1 parent a2157d0 commit f3b542a5bb40f8399ff1438569192bf531b422e9 @qerub qerub committed with Jul 5, 2008
Showing with 9 additions and 6 deletions.
  1. +9 −6 lib/rack/deflater.rb
View
15 lib/rack/deflater.rb
@@ -42,14 +42,17 @@ def self.gzip(body, mtime = Time.now)
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

0 comments on commit f3b542a

Please sign in to comment.
Something went wrong with that request. Please try again.