diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-07-01 13:59:40 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-07-01 14:12:07 -0700 |
commit | 06bf73975864b8e16ef1ee977f8424a0e5517fd6 (patch) | |
tree | edb02fb04b9edf26dc7a8b9add0c5e5c6e43d8aa /test/unit | |
parent | ec5d374768ced6aba3fed8a9481d2ac3c07cdb98 (diff) | |
download | unicorn-06bf73975864b8e16ef1ee977f8424a0e5517fd6.tar.gz |
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.
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/test_configurator.rb | 2 | ||||
-rw-r--r-- | test/unit/test_upload.rb | 19 |
2 files changed, 9 insertions, 12 deletions
diff --git a/test/unit/test_configurator.rb b/test/unit/test_configurator.rb index f836647..bcdd2f5 100644 --- a/test/unit/test_configurator.rb +++ b/test/unit/test_configurator.rb @@ -53,7 +53,6 @@ class TestConfigurator < Test::Unit::TestCase cfg = Unicorn::Configurator.new(:use_defaults => true) assert_nothing_raised { cfg.commit!(self) } Unicorn::Configurator::DEFAULTS.each do |key,value| - next if key == :stream_input assert_equal value, instance_variable_get("@#{key.to_s}") end end @@ -65,7 +64,6 @@ class TestConfigurator < Test::Unit::TestCase @logger = nil Unicorn::Configurator::DEFAULTS.each do |key,value| next if skip.include?(key) - next if key == :stream_input assert_equal value, instance_variable_get("@#{key.to_s}") end assert_nil @logger 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 |