From 60282ebfe5ddb283fc2312fb6a2ce9e928cb2ad9 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Fri, 2 Mar 2012 23:12:32 +0000 Subject: * lib/xmlrpc/client.rb (new2): fix custom port specification when an SSL uri is used. * test/xmlrpc/test_client.rb: tests for XMLRPC::Client.new2 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/xmlrpc/client.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/xmlrpc/client.rb b/lib/xmlrpc/client.rb index 968292b077..b9d4affeb2 100644 --- a/lib/xmlrpc/client.rb +++ b/lib/xmlrpc/client.rb @@ -279,6 +279,7 @@ require "xmlrpc/create" require "xmlrpc/config" require "xmlrpc/utils" # ParserWriterChooseMixin require "net/http" +require "uri" module XMLRPC @@ -344,15 +345,20 @@ module XMLRPC host, port = match[4].split(":") path = match[5] - if proto != "http" and proto != "https" + case proto + when 'http' then port ||= 80 + when 'https' then port ||= 443 + else raise "Wrong protocol specified. Only http or https allowed!" end + port = port.to_i else raise "Wrong URI as parameter!" end proxy_host, proxy_port = (proxy || "").split(":") + proxy_port = proxy_port.to_i if proxy_port self.new(host, path, port, proxy_host, proxy_port, user, passwd, (proto == "https"), timeout) end -- cgit v1.2.3