[前][次][番号順一覧][スレッド一覧]

ruby-changes:41246

From: kou <ko1@a...>
Date: Sat, 26 Dec 2015 18:33:54 +0900 (JST)
Subject: [ruby-changes:41246] kou:r53318 (trunk): * lib/xmlrpc/client.rb: Support SSL options in async methods of

kou	2015-12-26 18:33:43 +0900 (Sat, 26 Dec 2015)

  New Revision: 53318

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53318

  Log:
    * lib/xmlrpc/client.rb: Support SSL options in async methods of
      XMLRPC::Client.
      [Bug #11489]
      Reported by Aleksandar Kostadinov. Thanks!!!

  Modified files:
    trunk/ChangeLog
    trunk/lib/xmlrpc/client.rb
    trunk/test/xmlrpc/test_client.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53317)
+++ ChangeLog	(revision 53318)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Dec 26 18:29:01 2015  Kouhei Sutou  <kou@c...>
+
+	* 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  <naruse@r...>
 
 	* tool/post-commit.sh: copied from svn server.
Index: lib/xmlrpc/client.rb
===================================================================
--- lib/xmlrpc/client.rb	(revision 53317)
+++ lib/xmlrpc/client.rb	(revision 53318)
@@ -433,6 +433,24 @@ module XMLRPC # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/xmlrpc/client.rb#L433
       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: https://github.com/ruby/ruby/blob/trunk/lib/xmlrpc/client.rb#L482
 
       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: https://github.com/ruby/ruby/blob/trunk/lib/xmlrpc/client.rb#L627
   end # class Client
 
 end # module XMLRPC
-
Index: test/xmlrpc/test_client.rb
===================================================================
--- test/xmlrpc/test_client.rb	(revision 53317)
+++ test/xmlrpc/test_client.rb	(revision 53318)
@@ -10,10 +10,15 @@ end https://github.com/ruby/ruby/blob/trunk/test/xmlrpc/test_client.rb#L10
 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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]