about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-11-18 07:36:27 +0800
committerEric Wong <normalperson@yhbt.net>2010-11-18 07:36:27 +0800
commit3362dc51934c15fd944748e55ba4a470cc60d27d (patch)
tree483f0ed5401889855d104fd62cc19784e0397eb4 /test
parent390e351dd1283d4c80a12b744b1327fff091a141 (diff)
downloadunicorn-3362dc51934c15fd944748e55ba4a470cc60d27d.tar.gz
Any calls to read with an explicit zero length now returns an
empty string.  While not explicitly specified by Rack::Lint,
this is for compatibility with StringIO and IO methods which
are common in other web servers.
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_stream_input.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/unit/test_stream_input.rb b/test/unit/test_stream_input.rb
index 20e048d..adf4571 100644
--- a/test/unit/test_stream_input.rb
+++ b/test/unit/test_stream_input.rb
@@ -129,6 +129,23 @@ class TestStreamInput < Test::Unit::TestCase
     assert_equal '', buf
   end
 
+  def test_read_zero
+    r = init_request('hello')
+    si = Unicorn::StreamInput.new(@rd, r)
+    assert_equal '', si.read(0)
+    buf = 'asdf'
+    rv = si.read(0, buf)
+    assert_equal rv.object_id, buf.object_id
+    assert_equal '', buf
+    assert_equal 'hello', si.read
+    assert_nil si.read(5)
+    assert_equal '', si.read(0)
+    buf = 'hello'
+    rv = si.read(0, buf)
+    assert_equal rv.object_id, buf.object_id
+    assert_equal '', rv
+  end
+
   def init_request(body, size = nil)
     @parser = Unicorn::HttpParser.new
     body = body.to_s.freeze