summary refs log tree commit
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-01-17 18:35:33 -0800
committerEric Wong <normalperson@yhbt.net>2011-01-17 18:35:33 -0800
commitba059c17a6a38ac84893487219bf7bca2bed2b8f (patch)
treeb6d0b55e93adfd9f51a528a2e2a88dfbcbc7ea47
parent812ac75b327c9f3d6ff5074def9721bf6f19e1de (diff)
downloadrack-ba059c17a6a38ac84893487219bf7bca2bed2b8f.tar.gz
loosen deflater spec for zlib option changes
As long as zlib can properly deflate the response body with
the -Zlib::MAX_WBITS option, we'll consider it a valid
response.  The next commit will flush the buffer with each
chunk to allow for compressed streaming responses.
-rw-r--r--test/spec_deflater.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/test/spec_deflater.rb b/test/spec_deflater.rb
index f2e462af..43c8c95f 100644
--- a/test/spec_deflater.rb
+++ b/test/spec_deflater.rb
@@ -2,6 +2,7 @@ require 'stringio'
 require 'time'  # for Time#httpdate
 require 'rack/deflater'
 require 'rack/mock'
+require 'zlib'
 
 describe Rack::Deflater do
   def build_response(status, body, accept_encoding, headers = {})
@@ -13,6 +14,11 @@ describe Rack::Deflater do
     return response
   end
 
+  def inflate(buf)
+    inflater = Zlib::Inflate.new(-Zlib::MAX_WBITS)
+    inflater.inflate(buf) << inflater.finish
+  end
+
   should "be able to deflate bodies that respond to each" do
     body = Object.new
     class << body; def each; yield("foo"); yield("bar"); end; end
@@ -26,7 +32,7 @@ describe Rack::Deflater do
     })
     buf = ''
     response[2].each { |part| buf << part }
-    buf.should.equal("K\313\317OJ,\002\000")
+    inflate(buf).should.equal("foobar")
   end
 
   # TODO: This is really just a special case of the above...
@@ -40,7 +46,7 @@ describe Rack::Deflater do
     })
     buf = ''
     response[2].each { |part| buf << part }
-    buf.should.equal("\363H\315\311\311W(\317/\312IQ\004\000")
+    inflate(buf).should.equal("Hello world!")
   end
 
   should "be able to gzip bodies that respond to each" do