diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-08-09 03:02:54 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-08-09 03:11:34 -0700 |
commit | 81026ea66279695206ea53287427c05281662572 (patch) | |
tree | 14909515a565f77647e233de6c1b159d85c8a97e /test/unit/test_trailer_parser.rb | |
parent | 5b9d3e4a5ea5b5832f2b91fb9d6288c59b65a199 (diff) | |
download | unicorn-81026ea66279695206ea53287427c05281662572.tar.gz |
This should be more robust, faster and easier to deal with than the ugly proof-of-concept regexp-based ones.
Diffstat (limited to 'test/unit/test_trailer_parser.rb')
-rw-r--r-- | test/unit/test_trailer_parser.rb | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/test/unit/test_trailer_parser.rb b/test/unit/test_trailer_parser.rb deleted file mode 100644 index 5f3b16d..0000000 --- a/test/unit/test_trailer_parser.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'test/unit' -require 'unicorn' -require 'unicorn_http' -require 'unicorn/trailer_parser' - -class TestTrailerParser < Test::Unit::TestCase - - def test_basic - tp = Unicorn::TrailerParser.new('Content-MD5') - env = {} - assert ! tp.execute!(env, "Content-MD5: asdf") - assert env.empty? - assert tp.execute!(env, "Content-MD5: asdf\r\n") - assert_equal 'asdf', env['HTTP_CONTENT_MD5'] - assert_equal 1, env.size - end - - def test_invalid_trailer - tp = Unicorn::TrailerParser.new('Content-MD5') - env = {} - assert_raises(Unicorn::HttpParserError) { - tp.execute!(env, "Content-MD: asdf\r\n") - } - assert env.empty? - end - - def test_multiple_trailer - tp = Unicorn::TrailerParser.new('Foo,Bar') - env = {} - buf = "Bar: a\r\nFoo: b\r\n" - assert tp.execute!(env, buf) - assert_equal 'a', env['HTTP_BAR'] - assert_equal 'b', env['HTTP_FOO'] - end - - def test_too_big_key - tp = Unicorn::TrailerParser.new('Foo,Bar') - env = {} - buf = "Bar#{'a' * 1024}: a\r\nFoo: b\r\n" - assert_raises(Unicorn::HttpParserError) { tp.execute!(env, buf) } - assert env.empty? - end - - def test_too_big_value - tp = Unicorn::TrailerParser.new('Foo,Bar') - env = {} - buf = "Bar: #{'a' * (1024 * 1024)}: a\r\nFoo: b\r\n" - assert_raises(Unicorn::HttpParserError) { tp.execute!(env, buf) } - assert env.empty? - end - -end |