diff options
-rw-r--r-- | ext/unicorn_http/unicorn_http.rl | 1 | ||||
-rw-r--r-- | test/unit/test_http_parser_ng.rb | 25 |
2 files changed, 25 insertions, 1 deletions
diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl index 1e81c34..236fbaa 100644 --- a/ext/unicorn_http/unicorn_http.rl +++ b/ext/unicorn_http/unicorn_http.rl @@ -496,7 +496,6 @@ static VALUE HttpParser_reset(VALUE self) http_parser_init(hp); rb_funcall(hp->env, id_clear, 0); - rb_str_set_len(hp->buf, 0); return Qnil; } 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 |