Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…onstant
  • Loading branch information...
commit f3b542a5bb40f8399ff1438569192bf531b422e9 1 parent a2157d0
@qerub qerub authored chneukirchen committed
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
Please sign in to comment.
Something went wrong with that request. Please try again.