diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-11-13 16:41:10 +0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-11-13 16:41:10 +0800 |
commit | 17a734a9f6ccea8c969a574f09b5d8dd3d568a9c (patch) | |
tree | 30c3b8cccaa7b4807d105feebf6766166ad8e6b8 /test | |
parent | 855c02a9720a17854a2f1c715efbe502cdba54e2 (diff) | |
download | unicorn-17a734a9f6ccea8c969a574f09b5d8dd3d568a9c.tar.gz |
It's possible for an application to call size after it has read a few bytes/lines, so do not screw up a user's read offset when consuming input.
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/test_tee_input.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/unit/test_tee_input.rb b/test/unit/test_tee_input.rb index b44f609..e69c8f1 100644 --- a/test/unit/test_tee_input.rb +++ b/test/unit/test_tee_input.rb @@ -245,6 +245,28 @@ class TestTeeInput < Test::Unit::TestCase assert status.success? end + def test_chunked_and_size_slow + @parser = Unicorn::HttpParser.new + @buf = "POST / HTTP/1.1\r\n" \ + "Host: localhost\r\n" \ + "Trailer: Hello\r\n" \ + "Transfer-Encoding: chunked\r\n" \ + "\r\n" + assert_equal @env, @parser.headers(@env, @buf) + assert_equal "", @buf + + @wr.write("9\r\nabcde") + ti = TeeInput.new(@rd, @parser) + assert_nil @parser.content_length + assert_equal "abcde", ti.read(9) + assert ! @parser.body_eof? + @wr.write("fghi\r\n0\r\nHello: World\r\n\r\n") + assert_equal 9, ti.size + assert_equal "fghi", ti.read(9) + assert_equal nil, ti.read(9) + assert_equal "World", @env['HTTP_HELLO'] + end + private def init_request(body, size = nil) |