Permalink
Browse files

Updated Deflater configuration.

  • Loading branch information...
1 parent 9385496 commit 4e883dfd1dfe1134bb105ba80b0257acc053b762 @jakubpawlowicz committed Nov 14, 2012
Showing with 11 additions and 8 deletions.
  1. +11 −8 lib/rack/deflater.rb
View
19 lib/rack/deflater.rb
@@ -7,7 +7,10 @@ module Rack
class Deflater
def initialize(app, options = {})
@app = app
- @options = options
+
+ @min_content_length = options[:min_content_length]
+ @skip_if = options[:skip_if]
+ @exclude = options[:exclude]
end
def call(env)
@@ -110,21 +113,21 @@ def should_deflate?(env, status, headers, body)
end
# Skip if response body is too short
- if @options[:min_content_length] &&
- @options[:min_content_length] > headers['Content-Length'].to_i
+ if @min_content_length &&
+ @min_content_length > headers['Content-Length'].to_i
return false
end
# Skip if :exclude is provided and evaluates to true
- if @options[:exclude] &&
- @options[:exclude].kind_of?(Regexp) &&
- @options[:exclude].match(env['PATH_INFO'])
+ if @exclude &&
+ @exclude.kind_of?(Regexp) &&
+ @exclude.match(env['PATH_INFO'])
return false
end
# Skip if :skip_if lambda is provided and evaluates to true
- if @options[:skip_if] &&
- @options[:skip_if].call(env, status, headers, body)
+ if @skip_if &&
+ @skip_if.call(env, status, headers, body)
return false
end

0 comments on commit 4e883df

Please sign in to comment.