diff options
Diffstat (limited to 'test/unit/test_http_parser_ng.rb')
-rw-r--r-- | test/unit/test_http_parser_ng.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/unit/test_http_parser_ng.rb b/test/unit/test_http_parser_ng.rb index cb30f32..65b843e 100644 --- a/test/unit/test_http_parser_ng.rb +++ b/test/unit/test_http_parser_ng.rb @@ -388,6 +388,7 @@ class HttpParserNgTest < Test::Unit::TestCase "*" => { qs => "", pi => "" }, }.each do |uri,expect| assert_equal req, @parser.headers(req.clear, str % [ uri ]) + req = req.dup @parser.reset assert_equal uri, req["REQUEST_URI"], "REQUEST_URI mismatch" assert_equal expect[qs], req[qs], "#{qs} mismatch" @@ -412,6 +413,7 @@ class HttpParserNgTest < Test::Unit::TestCase "/1?a=b;c=d&e=f" => { qs => "a=b;c=d&e=f", pi => "/1" }, }.each do |uri,expect| assert_equal req, @parser.headers(req.clear, str % [ uri ]) + req = req.dup @parser.reset assert_equal uri, req["REQUEST_URI"], "REQUEST_URI mismatch" assert_equal "example.com", req["HTTP_HOST"], "Host: mismatch" @@ -440,6 +442,17 @@ class HttpParserNgTest < Test::Unit::TestCase end end + def test_backtrace_is_empty + begin + @parser.headers({}, "AAADFSFDSFD\r\n\r\n") + assert false, "should never get here line:#{__LINE__}" + rescue HttpParserError => e + assert_equal [], e.backtrace + return + end + assert false, "should never get here line:#{__LINE__}" + end + def test_ignore_version_header http = "GET / HTTP/1.1\r\nVersion: hello\r\n\r\n" req = {} @@ -460,4 +473,29 @@ class HttpParserNgTest < Test::Unit::TestCase assert_equal expect, req end + def test_pipelined_requests + expect = { + "HTTP_HOST" => "example.com", + "SERVER_NAME" => "example.com", + "REQUEST_PATH" => "/", + "rack.url_scheme" => "http", + "SERVER_PROTOCOL" => "HTTP/1.1", + "PATH_INFO" => "/", + "HTTP_VERSION" => "HTTP/1.1", + "REQUEST_URI" => "/", + "SERVER_PORT" => "80", + "REQUEST_METHOD" => "GET", + "QUERY_STRING" => "" + } + str = "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n" + @parser.buf << (str * 2) + env1 = @parser.parse.dup + assert_equal expect, env1 + assert_equal str, @parser.buf + assert @parser.keepalive? + @parser.reset + env2 = @parser.parse.dup + assert_equal expect, env2 + assert_equal "", @parser.buf + end end |