summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-08 14:27:38 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-08 14:27:38 +0000
commit48d780285894ecc3f0919e83b92a9c3f235d2632 (patch)
tree1df7f8008efc4fbfeea3f0ceb378ebb1c58e2628 /test
parent05bc6eb40a552355ab862e3db9171d5335deb751 (diff)
merge revision(s) 59693,59695: [Backport #13852]
A HTTP Header value must not contain CR or LF. to_str -> to_s * lib/net/http/header.rb (set_field): `val` can not have `to_str`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/net/http/test_httpheader.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/net/http/test_httpheader.rb b/test/net/http/test_httpheader.rb
index 99c47cac93..0a2c57dcb8 100644
--- a/test/net/http/test_httpheader.rb
+++ b/test/net/http/test_httpheader.rb
@@ -40,6 +40,13 @@ class HTTPHeaderTest < Test::Unit::TestCase
@c['aaA'] = 'aaa'
@c['AAa'] = 'aaa'
assert_equal 2, @c.length
+
+ @c['aaa'] = ['aaa', ['bbb', [3]]]
+ assert_equal 2, @c.length
+ assert_equal ['aaa', 'bbb', '3'], @c.get_fields('aaa')
+
+ assert_raise(ArgumentError){ @c['foo'] = "a\nb" }
+ assert_raise(ArgumentError){ @c['foo'] = ["a\nb"] }
end
def test_AREF
@@ -65,6 +72,10 @@ class HTTPHeaderTest < Test::Unit::TestCase
@c.add_field 'My-Header', 'd, d'
assert_equal 'a, b, c, d, d', @c['My-Header']
assert_equal ['a', 'b', 'c', 'd, d'], @c.get_fields('My-Header')
+ assert_raise(ArgumentError){ @c.add_field 'My-Header', "d\nd" }
+ @c.add_field 'My-Header', ['e', ['f', 7]]
+ assert_equal 'a, b, c, d, d, e, f, 7', @c['My-Header']
+ assert_equal ['a', 'b', 'c', 'd, d', 'e', 'f', '7'], @c.get_fields('My-Header')
end
def test_get_fields