summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-06-29 05:11:13 -0700
committerEric Wong <normalperson@yhbt.net>2009-06-29 05:11:13 -0700
commit2c53b32bf651966d3eb39850cc6be019eda51df0 (patch)
treef0287a19aef1e8270250fcf2ffa3c1a89ac0756f
parent0d3aa1eb6bc7646c9bde78b0fae4e34bc5876421 (diff)
-rw-r--r--test/unit/test_request.rb6
-rw-r--r--test/unit/test_server.rb2
-rw-r--r--test/unit/test_signals.rb2
-rw-r--r--test/unit/test_upload.rb12
4 files changed, 18 insertions, 4 deletions
diff --git a/test/unit/test_request.rb b/test/unit/test_request.rb
index 598a0f5..de35c05 100644
--- a/test/unit/test_request.rb
+++ b/test/unit/test_request.rb
@@ -150,7 +150,11 @@ class RequestTest < Test::Unit::TestCase
     assert_nothing_raised { env = @request.read(client) }
     assert ! env.include?(:http_body)
     assert_equal length, env['rack.input'].size
-    count.times { assert_equal buf, env['rack.input'].read(bs) }
+    count.times {
+      tmp = env['rack.input'].read(bs)
+      tmp << env['rack.input'].read(bs - tmp.size) if tmp.size != bs
+      assert_equal buf, tmp
+    }
     assert_nil env['rack.input'].read(bs)
     assert_nothing_raised { env['rack.input'].rewind }
     assert_nothing_raised { res = @lint.call(env) }
diff --git a/test/unit/test_server.rb b/test/unit/test_server.rb
index 0ce373f..22b9934 100644
--- a/test/unit/test_server.rb
+++ b/test/unit/test_server.rb
@@ -12,6 +12,8 @@ class TestHandler
 
   def call(env)
   #   response.socket.write("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nhello!\n")
+    while env['rack.input'].read(4096)
+    end
     [200, { 'Content-Type' => 'text/plain' }, ['hello!\n']]
    end
 end
diff --git a/test/unit/test_signals.rb b/test/unit/test_signals.rb
index ef66ed6..8ac4707 100644
--- a/test/unit/test_signals.rb
+++ b/test/unit/test_signals.rb
@@ -158,6 +158,8 @@ class SignalsTest < Test::Unit::TestCase
 
   def test_request_read
     app = lambda { |env|
+      while env['rack.input'].read(4096)
+      end
       [ 200, {'Content-Type'=>'text/plain', 'X-Pid'=>Process.pid.to_s}, [] ]
     }
     redirect_test_io { @server = HttpServer.new(app, @server_opts).start }
diff --git a/test/unit/test_upload.rb b/test/unit/test_upload.rb
index 4c0790f..b69ba4e 100644
--- a/test/unit/test_upload.rb
+++ b/test/unit/test_upload.rb
@@ -119,9 +119,15 @@ class UploadTest < Test::Unit::TestCase
     sock = TCPSocket.new(@addr, @port)
     buf = ' ' * @bs
     sock.syswrite("PUT / HTTP/1.0\r\nContent-Length: #{length}\r\n\r\n")
-    @count.times { sock.syswrite(buf) }
-    assert_raise(Errno::ECONNRESET, Errno::EPIPE) do
-      ::Unicorn::Const::CHUNK_SIZE.times { sock.syswrite(buf) }
+    if Unicorn::HttpRequest::DEFAULTS['unicorn.stream_input']
+      assert_raise(Errno::ECONNRESET, Errno::EPIPE) do
+        @count.times { sock.syswrite(buf) }
+      end
+    else
+      @count.times { sock.syswrite(buf) }
+      assert_raise(Errno::ECONNRESET, Errno::EPIPE) do
+        ::Unicorn::Const::CHUNK_SIZE.times { sock.syswrite(buf) }
+      end
     end
   end