about summary refs log tree commit homepage
path: root/test/test_rack_hijack.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_rack_hijack.rb')
-rw-r--r--test/test_rack_hijack.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test_rack_hijack.rb b/test/test_rack_hijack.rb
index 03c3051..2cc6b2d 100644
--- a/test/test_rack_hijack.rb
+++ b/test/test_rack_hijack.rb
@@ -20,6 +20,12 @@ class TestRackHijack < Testcase
 
   HIJACK_APP = lambda { |env|
     case env["PATH_INFO"]
+    when "/hijack_input"
+      io = env["rack.hijack"].call
+      env["rack.hijack_io"].write("HTTP/1.0 201 OK\r\n\r\n")
+      io.write("rack.input contents: #{env['rack.input'].read}")
+      io.close
+      return [ 500, {}, DieIfUsed.new ]
     when "/hijack_req"
       io = env["rack.hijack"].call
       if io.respond_to?(:read_nonblock) &&
@@ -64,6 +70,14 @@ class TestRackHijack < Testcase
     assert_equal 200, res.code.to_i
     assert_equal "zzz", res["X-Test"]
     assert_equal "1.1", res.http_version
+
+    res = Net::HTTP.start(host, port) do |h|
+      hdr = { "Content-Type" => 'application/octet-stream' }
+      h.put("/hijack_input", "BLAH", hdr)
+    end
+    assert_equal "rack.input contents: BLAH", res.body
+    assert_equal 201, res.code.to_i
+    assert_equal "1.0", res.http_version
   ensure
     quit_wait(pid)
   end