about summary refs log tree commit
path: root/test/rack_read_write.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rack_read_write.rb')
-rw-r--r--test/rack_read_write.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/rack_read_write.rb b/test/rack_read_write.rb
index b3a8a1f..46c1764 100644
--- a/test/rack_read_write.rb
+++ b/test/rack_read_write.rb
@@ -7,6 +7,52 @@ require 'rack'
 module TestRackReadWrite
   attr_reader :app
 
+  def test_rack_read_write_deflated
+    @app = Metropolis.new(:uri => uri, :encoding => :deflate)
+    basic_rest
+
+    blob = "." * 1024 * 1024
+    o = { :lint => true, :fatal => true }
+    req = Rack::MockRequest.new(app)
+
+    r = req.put("/asdf", o.merge(:input => blob))
+    assert_equal 201, r.status
+    assert_equal "Created\n", r.body
+
+    r = req.get("/asdf", o.merge("HTTP_ACCEPT_ENCODING" => "deflate"))
+    assert_equal 200, r.status
+    assert_equal "deflate", r.headers['Content-Encoding']
+    assert r.body.size < blob.size
+
+    r = req.get("/asdf", o.merge("HTTP_ACCEPT_ENCODING" => "gzip"))
+    assert_equal 200, r.status
+    assert_nil r.headers['Content-Encoding']
+    assert_equal blob, r.body
+  end
+
+  def test_rack_read_write_gzipped
+    @app = Metropolis.new(:uri => uri, :encoding => :gzip)
+    basic_rest
+
+    blob = "." * 1024 * 1024
+    o = { :lint => true, :fatal => true }
+    req = Rack::MockRequest.new(app)
+
+    r = req.put("/asdf", o.merge(:input => blob))
+    assert_equal 201, r.status
+    assert_equal "Created\n", r.body
+
+    r = req.get("/asdf", o.merge("HTTP_ACCEPT_ENCODING" => "gzip"))
+    assert_equal 200, r.status
+    assert_equal "gzip", r.headers['Content-Encoding']
+    assert r.body.size < blob.size
+
+    r = req.get("/asdf", o.merge("HTTP_ACCEPT_ENCODING" => "deflate"))
+    assert_equal 200, r.status
+    assert_nil r.headers['Content-Encoding']
+    assert_equal blob, r.body
+  end
+
   def test_rack_read_write
     @app = Metropolis.new(:uri => uri)
     basic_rest