From 3d8e4d6037d47d604a6670de333d3a931279b673 Mon Sep 17 00:00:00 2001 From: kou Date: Sat, 26 Dec 2015 09:33:43 +0000 Subject: [PATCH] * lib/xmlrpc/client.rb: Support SSL options in async methods of XMLRPC::Client. [Bug #11489] Reported by Aleksandar Kostadinov. Thanks!!! git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53318 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ lib/xmlrpc/client.rb | 24 +++++++++++++++++++----- test/xmlrpc/test_client.rb | 9 +++++++-- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 41b190e7f0..b82db2956e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Dec 26 18:29:01 2015 Kouhei Sutou + + * lib/xmlrpc/client.rb: Support SSL options in async methods of + XMLRPC::Client. + [Bug #11489] + Reported by Aleksandar Kostadinov. Thanks!!! + Sat Dec 26 18:21:17 2015 NARUSE, Yui * tool/post-commit.sh: copied from svn server. diff --git a/lib/xmlrpc/client.rb b/lib/xmlrpc/client.rb index 3cb9e9a9e9..587a80bea3 100644 --- a/lib/xmlrpc/client.rb +++ b/lib/xmlrpc/client.rb @@ -433,6 +433,24 @@ module XMLRPC # :nodoc: Net::HTTP.new host, port, proxy_host, proxy_port end + def dup_net_http + http = net_http(@http.address, + @http.port, + @http.proxy_address, + @http.proxy_port) + http.proxy_user = @http.proxy_user + http.proxy_pass = @http.proxy_pass + if @http.use_ssl? + http.use_ssl = true + Net::HTTP::SSL_ATTRIBUTES.each do |attribute| + http.__send__("#{attribute}=", @http.__send__(attribute)) + end + end + http.read_timeout = @http.read_timeout + http.open_timeout = @http.open_timeout + http + end + def set_auth if @user.nil? @auth = nil @@ -464,10 +482,7 @@ module XMLRPC # :nodoc: if async # use a new HTTP object for each call - http = net_http(@host, @port, @proxy_host, @proxy_port) - http.use_ssl = @use_ssl if @use_ssl - http.read_timeout = @timeout - http.open_timeout = @timeout + http = dup_net_http # post request http.start { @@ -612,4 +627,3 @@ module XMLRPC # :nodoc: end # class Client end # module XMLRPC - diff --git a/test/xmlrpc/test_client.rb b/test/xmlrpc/test_client.rb index 5a74c5265b..634de02d4d 100644 --- a/test/xmlrpc/test_client.rb +++ b/test/xmlrpc/test_client.rb @@ -10,10 +10,15 @@ end module XMLRPC class ClientTest < Test::Unit::TestCase module Fake - class HTTP - attr_accessor :read_timeout, :open_timeout, :use_ssl + class HTTP < Net::HTTP + class << self + def new(*args, &block) + Class.method(:new).unbind.bind(self).call(*args, &block) + end + end def initialize responses = {} + super("127.0.0.1") @started = false @responses = responses end