From db0f20a4c889a132786af69a6aaacfadf689379d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 3 Apr 2015 22:04:52 +0000 Subject: proxy_pass: test and fix larger uploads We were incorrectly stashing the return value of detach_rbuf! into the inter-thread buffer buffer which is bound to the client. --- test/test_proxy_pass.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'test') 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 -- cgit v1.2.3-24-ge0c7