summaryrefslogtreecommitdiff
path: root/lib/xmlrpc
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-02 23:46:17 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-02 23:46:17 +0000
commit1836f44fe937bce25e77bbd1c9b881e0df38b42c (patch)
tree62628356587795b452b249ca1f4121483b5dbadc /lib/xmlrpc
parentcd85cd25b4f129225d20d36fa5326e9e57901da0 (diff)
* lib/xmlrpc/client.rb (new2): use URI for uri parsing.
* test/xmlrpc/test_client.rb: test that query params are passed to the client constructor. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/xmlrpc')
-rw-r--r--lib/xmlrpc/client.rb29
1 files changed, 14 insertions, 15 deletions
diff --git a/lib/xmlrpc/client.rb b/lib/xmlrpc/client.rb
index d6495b55c4..e61d631b16 100644
--- a/lib/xmlrpc/client.rb
+++ b/lib/xmlrpc/client.rb
@@ -339,24 +339,23 @@ module XMLRPC
class << self
def new2(uri, proxy=nil, timeout=nil)
- if match = /^([^:]+):\/\/(([^@]+)@)?([^\/]+)(\/.*)?$/.match(uri)
- proto = match[1]
- user, passwd = (match[3] || "").split(":")
- host, port = match[4].split(":")
- path = match[5]
-
- case proto
- when 'http' then port ||= 80
- when 'https' then port ||= 443
- else
- raise ArgumentError, "Wrong protocol specified. Only http or https allowed!"
- end
+ begin
+ url = URI(uri)
+ rescue URI::InvalidURIError => e
+ raise ArgumentError, e.message, e.backtrace
+ end
- port = port.to_i
- else
- raise ArgumentError, "Wrong URI as parameter!"
+ unless URI::HTTP === url
+ raise ArgumentError, "Wrong protocol specified. Only http or https allowed!"
end
+ proto = url.scheme
+ user = url.user
+ passwd = url.password
+ host = url.host
+ port = url.port
+ path = url.path.empty? ? nil : url.request_uri
+
proxy_host, proxy_port = (proxy || "").split(":")
proxy_port = proxy_port.to_i if proxy_port