From ba059c17a6a38ac84893487219bf7bca2bed2b8f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 17 Jan 2011 18:35:33 -0800 Subject: 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. --- test/spec_deflater.rb | 10 ++++++++-- 1 file 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 -- cgit v1.2.3-24-ge0c7