about summary refs log tree commit homepage
path: root/test/test_extras_proxy_pass.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-03-03 07:54:55 +0000
committerEric Wong <e@80x24.org>2015-03-03 07:55:13 +0000
commit94538f003c4031f33eb6545032bd234e483e65c6 (patch)
tree0d66340d7d4e83668035c3f3d8c7f850b716023a /test/test_extras_proxy_pass.rb
parentc98942ca949e3d210c4c61939f1e3e18ccd466a8 (diff)
downloadyahns-94538f003c4031f33eb6545032bd234e483e65c6.tar.gz
This module will probably become an official part of yahns
soon, so finally add tests for this module.
Diffstat (limited to 'test/test_extras_proxy_pass.rb')
-rw-r--r--test/test_extras_proxy_pass.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/test/test_extras_proxy_pass.rb b/test/test_extras_proxy_pass.rb
index 513e574..8842683 100644
--- a/test/test_extras_proxy_pass.rb
+++ b/test/test_extras_proxy_pass.rb
@@ -59,6 +59,8 @@ class TestExtrasProxyPass < Testcase
       end
     end
 
+    gplv3 = File.open('COPYING')
+
     Net::HTTP.start(host, port) do |http|
       res = http.request(Net::HTTP::Get.new('/'))
       assert_equal 200, res.code.to_i
@@ -69,9 +71,29 @@ class TestExtrasProxyPass < Testcase
       assert_equal n, res['Content-Length'].to_i
       assert_nil res.body
 
-      res = http.put(Net::HTTP::Put.new('/'))
+      # chunked encoding
+      req = Net::HTTP::Put.new('/')
+      req.body_stream = gplv3
+      req.content_type = 'application/octet-stream'
+      req['Transfer-Encoding'] = 'chunked'
+      res = http.request(req)
+      gplv3.rewind
+      assert_equal gplv3.read, res.body
+      assert_equal 201, res.code.to_i
+
+      # normal content-length
+      gplv3.rewind
+      req = Net::HTTP::Put.new('/')
+      req.body_stream = gplv3
+      req.content_type = 'application/octet-stream'
+      req.content_length = gplv3.size
+      res = http.request(req)
+      gplv3.rewind
+      assert_equal gplv3.read, res.body
+      assert_equal 201, res.code.to_i
     end
   ensure
+    gplv3.close if gplv3
     quit_wait pid
     quit_wait pid2
   end