From 3a2634f3f68f6b8ea1aa7b2bb5944884bbfa8017 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 30 Dec 2010 02:30:19 +0000 Subject: tests: test parser works with keepalive_requests=0 We use this in Rainbows! to disable keepalive in certain configurations. --- test/unit/test_http_parser_ng.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/unit/test_http_parser_ng.rb b/test/unit/test_http_parser_ng.rb index c5d2460..e080d9c 100644 --- a/test/unit/test_http_parser_ng.rb +++ b/test/unit/test_http_parser_ng.rb @@ -608,4 +608,26 @@ class HttpParserNgTest < Test::Unit::TestCase assert_equal expect, env2 assert_equal "", @parser.buf end + + def test_keepalive_requests_disabled + req = "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n".freeze + expect = { + "SERVER_NAME" => "example.com", + "HTTP_HOST" => "example.com", + "rack.url_scheme" => "http", + "REQUEST_PATH" => "/", + "SERVER_PROTOCOL" => "HTTP/1.1", + "PATH_INFO" => "/", + "HTTP_VERSION" => "HTTP/1.1", + "REQUEST_URI" => "/", + "SERVER_PORT" => "80", + "REQUEST_METHOD" => "GET", + "QUERY_STRING" => "" + }.freeze + HttpParser.keepalive_requests = 0 + @parser = HttpParser.new + @parser.buf << req + assert_equal expect, @parser.parse + assert ! @parser.next? + end end -- cgit v1.2.3-24-ge0c7