aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/open-uri.rb22
2 files changed, 22 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 7bbc78eaef..0978b4e793 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Oct 1 01:46:51 2005 Tanaka Akira <akr@m17n.org>
+
+ * lib/open-uri.rb (OpenURI.open_loop): prohibit multiple proxy
+ options.
+
Thu Sep 29 10:26:18 2005 Tanaka Akira <akr@m17n.org>
* ext/dl/cptr.c (rb_dlptr_s_to_ptr): abolish sizeof(FILE).
diff --git a/lib/open-uri.rb b/lib/open-uri.rb
index daa5a87b54..b57156bbc9 100644
--- a/lib/open-uri.rb
+++ b/lib/open-uri.rb
@@ -147,15 +147,27 @@ module OpenURI
end
def OpenURI.open_loop(uri, options) # :nodoc:
- if options.include? :proxy_http_basic_authentication
- opt_proxy, proxy_user, proxy_pass = options[:proxy_http_basic_authentication]
+ proxy_opts = []
+ proxy_opts << :proxy_http_basic_authentication if options.include? :proxy_http_basic_authentication
+ proxy_opts << :proxy if options.include? :proxy
+ proxy_opts.compact!
+ if 1 < proxy_opts.length
+ raise ArgumentError, "multiple proxy options specified"
+ end
+ case proxy_opts.first
+ when :proxy_http_basic_authentication
+ opt_proxy, proxy_user, proxy_pass = options.fetch(:proxy_http_basic_authentication)
proxy_user = proxy_user.to_str
proxy_pass = proxy_pass.to_str
if opt_proxy == true
raise ArgumentError.new("Invalid authenticated proxy option: #{options[:proxy_http_basic_authentication].inspect}")
end
- else
- opt_proxy = options.fetch(:proxy, true)
+ when :proxy
+ opt_proxy = options.fetch(:proxy)
+ proxy_user = nil
+ proxy_pass = nil
+ when nil
+ opt_proxy = true
proxy_user = nil
proxy_pass = nil
end
@@ -511,7 +523,7 @@ module OpenURI
# If nil is given for the proxy URI, this option is just ignored.
#
# If :proxy and :proxy_http_basic_authentication is specified,
- # :proxy_http_basic_authentication is preferred.
+ # ArgumentError is raised.
#
# [:http_basic_authentication]
# Synopsis: