Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some small changes & adjustments.

  • Loading branch information...
commit 938549654161b6353930614b66d5256f29fe9a56 1 parent ea2abf2
@jakubpawlowicz authored
Showing with 16 additions and 3 deletions.
  1. +4 −3 lib/rack/deflater.rb
  2. +12 −0 test/spec_deflater.rb
View
7 lib/rack/deflater.rb
@@ -115,15 +115,16 @@ def should_deflate?(env, status, headers, body)
return false
end
- # Skip if paths :exclude is provided and evaluates to true
+ # Skip if :exclude is provided and evaluates to true
if @options[:exclude] &&
@options[:exclude].kind_of?(Regexp) &&
@options[:exclude].match(env['PATH_INFO'])
return false
end
- # Skip if :skip_if lambda is provided and it evaluates to true
- if @options[:skip_if] && @options[:skip_if].call(env, status, headers, body)
+ # Skip if :skip_if lambda is provided and evaluates to true
+ if @options[:skip_if] &&
+ @options[:skip_if].call(env, status, headers, body)
return false
end
View
12 test/spec_deflater.rb
@@ -217,6 +217,18 @@ class << body; def each; yield("foo"); yield("bar"); end; end
Enumerator.new(response[2]).to_a.join.should.equal("Hello World!")
end
+ should "do nothing if Content-Length is not given" do
+ body = 'Hello World!'
+ app = lambda do |env|
+ [200, {'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s }, [body]]
+ end
+ request = Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => "gzip")
+ response = deflater(app, { min_content_length: body.length + 1 }).call(request)
+
+ response[0].should.equal(200)
+ Enumerator.new(response[2]).to_a.join.should.equal("Hello World!")
+ end
+
should "gzip response if body length is equal or longer than a given threshold" do
body = 'Hello World!'
app = lambda do |env|

0 comments on commit 9385496

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