From 06bf73975864b8e16ef1ee977f8424a0e5517fd6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 1 Jul 2009 13:59:40 -0700 Subject: Force streaming input onto apps by default This change gives applications full control to deny clients from uploading unwanted message bodies. This also paves the way for doing things like upload progress notification within applications in a Rack::Lint-compatible manner. Since we don't support HTTP keepalive, so we have more freedom here by being able to close TCP connections and deny clients the ability to write to us (and thus wasting our bandwidth). While I could've left this feature off by default indefinitely for maximum backwards compatibility (for arguably broken applications), Unicorn is not and has never been about supporting the lowest common denominator. --- test/unit/test_upload.rb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'test/unit/test_upload.rb') diff --git a/test/unit/test_upload.rb b/test/unit/test_upload.rb index 37baa30..dad5825 100644 --- a/test/unit/test_upload.rb +++ b/test/unit/test_upload.rb @@ -142,20 +142,19 @@ class UploadTest < Test::Unit::TestCase end def test_put_excessive_overwrite_closed - start_server(lambda { |env| [ 200, @hdr, [] ] }) + start_server(lambda { |env| + while env['rack.input'].read(65536); end + [ 200, @hdr, [] ] + }) sock = TCPSocket.new(@addr, @port) buf = ' ' * @bs sock.syswrite("PUT / HTTP/1.0\r\nContent-Length: #{length}\r\n\r\n") - 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 + + @count.times { sock.syswrite(buf) } + 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 end # Despite reading numerous articles and inspecting the 1.9.1-p0 C -- cgit v1.2.3-24-ge0c7