ruby-changes:29233
From: kou <ko1@a...>
Date: Thu, 13 Jun 2013 22:47:08 +0900 (JST)
Subject: [ruby-changes:29233] kou:r41285 (trunk): * lib/xmlrpc/client.rb (XMLRPC::Client#parse_set_cookies): Support
kou 2013-06-13 22:46:54 +0900 (Thu, 13 Jun 2013) New Revision: 41285 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41285 Log: * lib/xmlrpc/client.rb (XMLRPC::Client#parse_set_cookies): Support multiple names in a response. [ruby-core:41711] [Bug #5774] Reported by Roman Riha. Thanks!!! * test/xmlrpc/test_client.rb (XMLRPC::ClientTest#test_cookie_override): Add a test of the above case. Modified files: trunk/ChangeLog trunk/lib/xmlrpc/client.rb trunk/test/xmlrpc/test_client.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 41284) +++ ChangeLog (revision 41285) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Jun 13 22:44:52 2013 Kouhei Sutou <kou@c...> + + * lib/xmlrpc/client.rb (XMLRPC::Client#parse_set_cookies): Support + multiple names in a response. [ruby-core:41711] [Bug #5774] + Reported by Roman Riha. Thanks!!! + * test/xmlrpc/test_client.rb (XMLRPC::ClientTest#test_cookie_override): + Add a test of the above case. + Thu Jun 13 22:35:50 2013 Kouhei Sutou <kou@c...> * lib/xmlrpc/client.rb (XMLRPC::Client#parse_set_cookies): Use Index: lib/xmlrpc/client.rb =================================================================== --- lib/xmlrpc/client.rb (revision 41284) +++ lib/xmlrpc/client.rb (revision 41285) @@ -515,10 +515,16 @@ module XMLRPC # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/xmlrpc/client.rb#L515 return if set_cookies.nil? return if set_cookies.empty? require 'webrick/cookie' - @cookie = set_cookies.collect do |set_cookie| + pairs = {} + set_cookies.each do |set_cookie| cookie = WEBrick::Cookie.parse_set_cookie(set_cookie) - WEBrick::Cookie.new(cookie.name, cookie.value).to_s - end.join("; ") + pairs.delete(cookie.name) + pairs[cookie.name] = cookie.value + end + cookies = pairs.collect do |name, value| + WEBrick::Cookie.new(name, value).to_s + end + @cookie = cookies.join("; ") end def gen_multicall(methods=[], async=false) Index: test/xmlrpc/test_client.rb =================================================================== --- test/xmlrpc/test_client.rb (revision 41284) +++ test/xmlrpc/test_client.rb (revision 41285) @@ -287,6 +287,17 @@ module XMLRPC https://github.com/ruby/ruby/blob/trunk/test/xmlrpc/test_client.rb#L287 assert_equal("param1=value1; param2=value2", client.cookie) end + def test_cookie_override + client = Fake::Client.new2('http://example.org/cookie') + client.send(:parse_set_cookies, + [ + "param1=value1", + "param2=value2", + "param1=value3", + ]) + assert_equal("param2=value2; param1=value3", client.cookie) + end + private def read filename File.read File.expand_path(File.join(__FILE__, '..', 'data', filename)) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/