about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-04-03 22:04:52 +0000
committerEric Wong <e@80x24.org>2015-04-03 22:04:52 +0000
commitdb0f20a4c889a132786af69a6aaacfadf689379d (patch)
treefd8f75165536fadb5d026ae2e6951267ebe68728 /test
parent78f23338ef08fe98e7d90d35ba1f8356de51e3d4 (diff)
downloadyahns-db0f20a4c889a132786af69a6aaacfadf689379d.tar.gz
We were incorrectly stashing the return value of detach_rbuf!
into the inter-thread buffer buffer which is bound to the client.
Diffstat (limited to 'test')
-rw-r--r--test/test_proxy_pass.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/test/test_proxy_pass.rb b/test/test_proxy_pass.rb
index 5bf8722..53542ac 100644
--- a/test/test_proxy_pass.rb
+++ b/test/test_proxy_pass.rb
@@ -144,6 +144,7 @@ class TestProxyPass < Testcase
       cfg.instance_eval do
         app(:rack, Yahns::ProxyPass.new("http://#{host2}:#{port2}")) do
           listen "#{host}:#{port}"
+          client_max_body_size nil
         end
         stderr_path err.path
       end
@@ -154,6 +155,7 @@ class TestProxyPass < Testcase
       cfg.instance_eval do
         app(:rack, ProxiedApp.new) do
           listen "#{host2}:#{port2}"
+          client_max_body_size nil
         end
         stderr_path err.path
       end
@@ -195,7 +197,7 @@ class TestProxyPass < Testcase
       assert_equal 'text/PAIN', res['Content-Type']
       assert_equal 'HIHIHI!', res.body
 
-      # normal content-length
+      # normal content-length (PUT)
       gplv3.rewind
       req = Net::HTTP::Put.new('/')
       req.body_stream = gplv3
@@ -210,6 +212,24 @@ class TestProxyPass < Testcase
       res = http.request(Net::HTTP::Get.new('/giant-body'))
       assert_equal 200, res.code.to_i
       assert_equal OMFG, res.body
+
+      # giant PUT content-length
+      req = Net::HTTP::Put.new('/')
+      req.body_stream = StringIO.new(OMFG)
+      req.content_type = 'application/octet-stream'
+      req.content_length = OMFG.size
+      res = http.request(req)
+      assert_equal OMFG, res.body
+      assert_equal 201, res.code.to_i
+
+      # giant PUT chunked encoding
+      req = Net::HTTP::Put.new('/')
+      req.body_stream = StringIO.new(OMFG)
+      req.content_type = 'application/octet-stream'
+      req['Transfer-Encoding'] = 'chunked'
+      res = http.request(req)
+      assert_equal OMFG, res.body
+      assert_equal 201, res.code.to_i
     end
 
     # ensure we do not chunk responses back to an HTTP/1.0 client even if