From c3bc5864d0b8c56adee9544b64c9182d8d4eb206 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 6 Jun 2015 01:07:55 +0000 Subject: http: move response_start_sent into the C ext Combined with the previous commit to eliminate the `@socket' instance variable, this eliminates the last instance variable in the Unicorn::HttpRequest class. Eliminating the last instance variable avoids the creation of a internal hash table used for implementing the "generic" instance variables found in non-pure-Ruby classes. Method entry overhead remains the same. While this change doesn't do a whole lot for unicorn memory usage where the HttpRequest is a singleton, it helps other HTTP servers which rely on this code where thousands of clients may be connected. --- test/unit/test_http_parser_ng.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/unit/test_http_parser_ng.rb b/test/unit/test_http_parser_ng.rb index efd82e1..d186f5a 100644 --- a/test/unit/test_http_parser_ng.rb +++ b/test/unit/test_http_parser_ng.rb @@ -34,6 +34,17 @@ class HttpParserNgTest < Test::Unit::TestCase assert_equal false, @parser.response_start_sent end + def test_response_start_sent + assert_equal false, @parser.response_start_sent, "default is false" + @parser.response_start_sent = true + assert_equal true, @parser.response_start_sent + @parser.response_start_sent = false + assert_equal false, @parser.response_start_sent + @parser.response_start_sent = true + @parser.clear + assert_equal false, @parser.response_start_sent + end + def test_connection_TE @parser.buf << "GET / HTTP/1.1\r\nHost: example.com\r\nConnection: TE\r\n" @parser.buf << "TE: trailers\r\n\r\n" -- cgit v1.2.3-24-ge0c7