ruby-changes:37463
From: hsbt <ko1@a...>
Date: Sun, 8 Feb 2015 20:10:04 +0900 (JST)
Subject: [ruby-changes:37463] hsbt:r49544 (trunk): * lib/net/http/header.rb: pass header names as symbols.
hsbt 2015-02-08 20:09:44 +0900 (Sun, 08 Feb 2015) New Revision: 49544 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49544 Log: * lib/net/http/header.rb: pass header names as symbols. Patch by @DamirSvrtan [fix GH-805] * test/net/http/test_httpheader.rb: added test. Modified files: trunk/ChangeLog trunk/lib/net/http/header.rb trunk/test/net/http/test_httpheader.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 49543) +++ ChangeLog (revision 49544) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Feb 8 20:09:37 2015 SHIBATA Hiroshi <shibata.hiroshi@g...> + + * lib/net/http/header.rb: pass header names as symbols. + Patch by @DamirSvrtan [fix GH-805] + * test/net/http/test_httpheader.rb: added test. + Sun Feb 8 13:04:25 2015 Nobuyoshi Nakada <nobu@r...> * ext/socket/getaddrinfo.c (get_addr): reject too long hostname to Index: lib/net/http/header.rb =================================================================== --- lib/net/http/header.rb (revision 49543) +++ lib/net/http/header.rb (revision 49544) @@ -169,7 +169,7 @@ module Net::HTTPHeader https://github.com/ruby/ruby/blob/trunk/lib/net/http/header.rb#L169 alias canonical_each each_capitalized def capitalize(name) - name.split(/-/).map {|s| s.capitalize }.join('-') + name.to_s.split(/-/).map {|s| s.capitalize }.join('-') end private :capitalize Index: test/net/http/test_httpheader.rb =================================================================== --- test/net/http/test_httpheader.rb (revision 49543) +++ test/net/http/test_httpheader.rb (revision 49544) @@ -142,6 +142,14 @@ class HTTPHeaderTest < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/net/http/test_httpheader.rb#L142 end end + def test_each_capitalized_with_symbol + @c[:my_header] = ['a', 'b'] + @c.each_capitalized do |k,v| + assert_equal "My_header", k + assert_equal 'a, b', v + end + end + def test_key? @c['My-Header'] = 'test' assert_equal true, @c.key?('My-Header') -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/