mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
r22139@crimson: knu | 2009-02-08 21:52:57 +0900
(OpenURI.open_loop): prohibit multiple proxy options. (r9339) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@22150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8bb303a505
commit
6570774cac
2 changed files with 18 additions and 5 deletions
|
@ -3,6 +3,7 @@ Sun Feb 8 21:39:06 2009 Akinori MUSHA <knu@iDaemons.org>
|
|||
* lib/open-uri.rb: add :read_timeout option.
|
||||
[ruby-core:4848] (r9166)
|
||||
(:proxy_http_basic_authentication): new option. (r9336)
|
||||
(OpenURI.open_loop): prohibit multiple proxy options. (r9339)
|
||||
|
||||
Mon Feb 9 01:21:16 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
|
|
|
@ -144,15 +144,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
|
||||
|
@ -498,7 +510,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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue