about summary refs log tree commit homepage
path: root/test/unit/test_http_parser.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/test_http_parser.rb')
-rw-r--r--test/unit/test_http_parser.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/unit/test_http_parser.rb b/test/unit/test_http_parser.rb
index 31e6f71..697af44 100644
--- a/test/unit/test_http_parser.rb
+++ b/test/unit/test_http_parser.rb
@@ -865,4 +865,20 @@ class HttpParserTest < Test::Unit::TestCase
   rescue LoadError
     # not all Ruby implementations have objspace
   end
+
+  def test_dedupe
+    parser = HttpParser.new
+    # n.b. String#freeze optimization doesn't work under modern test-unit
+    exp = -'HTTP_HOST'
+    get = "GET / HTTP/1.1\r\nHost: example.com\r\nHavpbea-fhpxf: true\r\n\r\n"
+    assert parser.add_parse(get)
+    key = parser.env.keys.detect { |k| k == exp }
+    assert_same exp, key
+
+    if RUBY_VERSION.to_r >= 2.6 # 2.6.0-rc1+
+      exp = -'HTTP_HAVPBEA_FHPXF'
+      key = parser.env.keys.detect { |k| k == exp }
+      assert_same exp, key
+    end
+  end if RUBY_VERSION.to_r >= 2.5 && RUBY_ENGINE == 'ruby'
 end