about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-12-30 02:30:19 +0000
committerEric Wong <normalperson@yhbt.net>2010-12-30 02:30:19 +0000
commit3a2634f3f68f6b8ea1aa7b2bb5944884bbfa8017 (patch)
tree73bebb3abecc91ed9ad6ae25e7f71fb573c868bf
parent2c57f59172c45a3ca52dbddfb3f12c1bc70cbfd6 (diff)
downloadunicorn-3a2634f3f68f6b8ea1aa7b2bb5944884bbfa8017.tar.gz
We use this in Rainbows! to disable keepalive in certain
configurations.
-rw-r--r--test/unit/test_http_parser_ng.rb22
1 files changed, 22 insertions, 0 deletions
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