about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-01-31 15:50:37 -0800
committerEric Wong <normalperson@yhbt.net>2011-01-31 15:50:37 -0800
commite3420e0ae1f3c38f125010134d2cdeb22c6fa64e (patch)
tree48b2a6e279bf68de29a4921a7a0054abebe91ae6
parentf4caf6b6bdea902abaadd3c04b2af94f056c4ff1 (diff)
downloadunicorn-e3420e0ae1f3c38f125010134d2cdeb22c6fa64e.tar.gz
The client may not get a proper response with TCP_CORK enabled
-rw-r--r--test/unit/test_upload.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/test/unit/test_upload.rb b/test/unit/test_upload.rb
index dc0eb40..e2c103a 100644
--- a/test/unit/test_upload.rb
+++ b/test/unit/test_upload.rb
@@ -145,8 +145,14 @@ class UploadTest < Test::Unit::TestCase
   end
 
   def test_put_excessive_overwrite_closed
+    tmp = Tempfile.new('overwrite_check')
+    tmp.sync = true
     start_server(lambda { |env|
-      while env['rack.input'].read(65536); end
+      nr = 0
+      while buf = env['rack.input'].read(65536)
+        nr += buf.size
+      end
+      tmp.write(nr.to_s)
       [ 200, @hdr, [] ]
     })
     sock = TCPSocket.new(@addr, @port)
@@ -157,7 +163,9 @@ class UploadTest < Test::Unit::TestCase
     assert_raise(Errno::ECONNRESET, Errno::EPIPE) do
       ::Unicorn::Const::CHUNK_SIZE.times { sock.syswrite(buf) }
     end
-    assert_equal "HTTP/1.1 200 OK\r\n", sock.gets
+    assert_nothing_raised { sock.gets }
+    tmp.rewind
+    assert_equal length, tmp.read.to_i
   end
 
   # Despite reading numerous articles and inspecting the 1.9.1-p0 C