diff options
author | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-10-24 23:22:16 +0000 |
---|---|---|
committer | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-10-24 23:22:16 +0000 |
commit | 6b55d11c08daafc8e4ec84fb04efc29c8adc7bd8 (patch) | |
tree | e15c7e88edd137bc0533fcf6e02e73030d20a1ca /test | |
parent | a75e81b14f14dfc935e18dcddcaca59179e2e625 (diff) | |
download | unicorn-6b55d11c08daafc8e4ec84fb04efc29c8adc7bd8.tar.gz |
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@366 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'test')
-rw-r--r-- | test/test_handlers.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/test/test_handlers.rb b/test/test_handlers.rb index 7df0f15..98f83c0 100644 --- a/test/test_handlers.rb +++ b/test/test_handlers.rb @@ -45,7 +45,7 @@ class HandlersTest < Test::Unit::TestCase uri "/", :handler => SimpleHandler.new uri "/", :handler => stats uri "/404", :handler => Mongrel::Error404Handler.new("Not found") - uri "/dumb", :handler => Mongrel::DeflateFilter.new(:always_deflate => true) + uri "/dumb", :handler => Mongrel::DeflateFilter.new uri "/dumb", :handler => DumbHandler.new, :in_front => true uri "/files", :handler => Mongrel::DirHandler.new("doc") uri "/files_nodir", :handler => Mongrel::DirHandler.new("doc",listing_allowed=false, index_html="none") @@ -73,8 +73,21 @@ class HandlersTest < Test::Unit::TestCase check_status res, String end - def test_deflate_access - req = Net::HTTP::Get.new("http://localhost:9998/dumb") + def test_deflate + Net::HTTP.start("localhost", 9998) do |h| + # test that no accept-encoding returns a non-deflated response + req = h.get("/dumb") + assert( + !req.header['Content-Encoding'] || + !req.header['Content-Encoding'].include?('deflate')) + assert_equal "test", req.body + + req = h.get("/dumb", {"Accept-Encoding" => "deflate"}) + # -MAX_WBITS stops zlib from looking for a zlib header + inflater = Zlib::Inflate.new(-Zlib::MAX_WBITS) + assert req.header['Content-Encoding'].include?('deflate') + assert_equal "test", inflater.inflate(req.body) + end end # TODO: find out why this fails on win32 but nowhere else |