From 81026ea66279695206ea53287427c05281662572 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 9 Aug 2009 03:02:54 -0700 Subject: Switch to Ragel/C-based chunk/trailer parser This should be more robust, faster and easier to deal with than the ugly proof-of-concept regexp-based ones. --- test/unit/test_tee_input.rb | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'test/unit/test_tee_input.rb') diff --git a/test/unit/test_tee_input.rb b/test/unit/test_tee_input.rb index a6c61e6..3a6c998 100644 --- a/test/unit/test_tee_input.rb +++ b/test/unit/test_tee_input.rb @@ -26,7 +26,8 @@ class TestTeeInput < Test::Unit::TestCase end def test_gets_long - ti = Unicorn::TeeInput.new(@rd, nil, "hello") + init_parser("hello", 5 + (4096 * 4 * 3) + "#$/foo#$/".size) + ti = Unicorn::TeeInput.new(@rd) status = line = nil pid = fork { @rd.close @@ -46,7 +47,8 @@ class TestTeeInput < Test::Unit::TestCase end def test_gets_short - ti = Unicorn::TeeInput.new(@rd, nil, "hello") + init_parser("hello", 5 + "#$/foo".size) + ti = Unicorn::TeeInput.new(@rd) status = line = nil pid = fork { @rd.close @@ -63,4 +65,19 @@ class TestTeeInput < Test::Unit::TestCase assert status.success? end +private + + def init_parser(body, size = nil) + @parser = Unicorn::TeeInput::PARSER + @parser.reset + body = body.to_s.freeze + buf = "POST / HTTP/1.1\r\n" \ + "Host: localhost\r\n" \ + "Content-Length: #{size || body.size}\r\n" \ + "\r\n#{body}" + buf = Unicorn::TeeInput::RAW.replace(buf) + assert_equal @env, @parser.headers(@env, buf) + assert_equal body, buf + end + end -- cgit v1.2.3-24-ge0c7