summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-13 13:46:54 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-13 13:46:54 +0000
commit16d5c80678042e7d9f42c022ba7b1816f15611ad (patch)
tree7896423107851461459a54b2e6fdc4a8b8b9c719
parent102e2cd5633b3e7f685a2dc6d3339d4598638585 (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--lib/xmlrpc/client.rb12
-rw-r--r--test/xmlrpc/test_client.rb11
3 files changed, 28 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c360b2753e0..a1f23d5a974 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Jun 13 22:44:52 2013 Kouhei Sutou <kou@cozmixng.org>
+
+ * 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@cozmixng.org>
* lib/xmlrpc/client.rb (XMLRPC::Client#parse_set_cookies): Use
diff --git a/lib/xmlrpc/client.rb b/lib/xmlrpc/client.rb
index 547eca88199..f213fdf8d13 100644
--- a/lib/xmlrpc/client.rb
+++ b/lib/xmlrpc/client.rb
@@ -515,10 +515,16 @@ module XMLRPC # :nodoc:
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)
diff --git a/test/xmlrpc/test_client.rb b/test/xmlrpc/test_client.rb
index c888a9837f7..35559d23c48 100644
--- a/test/xmlrpc/test_client.rb
+++ b/test/xmlrpc/test_client.rb
@@ -287,6 +287,17 @@ module XMLRPC
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))