about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-10-07 08:12:36 +0000
committerEric Wong <normalperson@yhbt.net>2010-10-07 08:14:14 +0000
commite99178ef89eca9e46b73484aaf9733259dac9dca (patch)
tree52098695f4b7fff6ce11839edcd929cda9204849 /test
parenteb5ba488422020568e5ccf650891d7fccce7238f (diff)
downloadunicorn-e99178ef89eca9e46b73484aaf9733259dac9dca.tar.gz
We cannot clear the buffer between requests because
clients may send multiple requests that get taken in
one read()/recv() call.
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_http_parser_ng.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/unit/test_http_parser_ng.rb b/test/unit/test_http_parser_ng.rb
index ec82b8a..65b843e 100644
--- a/test/unit/test_http_parser_ng.rb
+++ b/test/unit/test_http_parser_ng.rb
@@ -473,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