mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/open-uri.rb (URI::Generic#find_proxy): use http_proxy under CGI
if the environment variable is case sensitive. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f1d89b24da
commit
a3388b68b7
2 changed files with 31 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Nov 25 17:52:11 2003 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
|
* lib/open-uri.rb (URI::Generic#find_proxy): use http_proxy under CGI
|
||||||
|
if the environment variable is case sensitive.
|
||||||
|
|
||||||
Tue Nov 25 16:41:33 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
|
Tue Nov 25 16:41:33 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
|
||||||
|
|
||||||
* test/wsdl/multiplefault.wsdl, test/wsdl/test_multiplefault.rb:
|
* test/wsdl/multiplefault.wsdl, test/wsdl/test_multiplefault.rb:
|
||||||
|
|
|
@ -443,16 +443,35 @@ module URI
|
||||||
# ftp_proxy, no_proxy, etc.
|
# ftp_proxy, no_proxy, etc.
|
||||||
# If there is no proper proxy, nil is returned.
|
# If there is no proper proxy, nil is returned.
|
||||||
#
|
#
|
||||||
# The enveironment variable CGI_http_proxy and CGI_HTTP_PROXY is used
|
# Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.)
|
||||||
# instead of http_proxy and HTTP_PROXY in the CGI environment because
|
# are examined too.
|
||||||
# HTTP_PROXY can be set by Proxy: header sent by a CGI client.
|
#
|
||||||
|
# But http_proxy and HTTP_PROXY is treated specially under CGI environment.
|
||||||
|
# It's because HTTP_PROXY may be set by Proxy: header.
|
||||||
|
# So HTTP_PROXY is not used.
|
||||||
|
# http_proxy is not used too if the variable is case insentitive.
|
||||||
|
# CGI_HTTP_PROXY can be used instead.
|
||||||
def find_proxy
|
def find_proxy
|
||||||
name = self.scheme.downcase + '_proxy'
|
name = self.scheme.downcase + '_proxy'
|
||||||
if ENV.include? 'REQUEST_METHOD' # in CGI?
|
proxy_uri = nil
|
||||||
# Use CGI_HTTP_PROXY. cf. libwww-perl.
|
if name == 'http_proxy' && ENV.include?('REQUEST_METHOD') # CGI?
|
||||||
name = "CGI_#{name}" if /\Ahttp_/i =~ name
|
# HTTP_PROXY conflicts with *_proxy for proxy settings and
|
||||||
|
# HTTP_* for header informatin in CGI.
|
||||||
|
# So it should be careful to use it.
|
||||||
|
case_sentsitive = /djgpp|bccwin32|mingw|mswin32|mswince|emx/ !~ RUBY_PLATFORM
|
||||||
|
if case_sentsitive
|
||||||
|
# http_proxy is safe to use.
|
||||||
|
proxy_uri = ENV[name]
|
||||||
|
end
|
||||||
|
if !proxy_uri
|
||||||
|
# Use CGI_HTTP_PROXY. cf. libwww-perl.
|
||||||
|
proxy_uri = ENV["CGI_#{name.upcase}"]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
proxy_uri = ENV[name] || ENV[name.upcase]
|
||||||
end
|
end
|
||||||
if proxy_uri = ENV[name] || ENV[name.upcase]
|
|
||||||
|
if proxy_uri
|
||||||
proxy_uri = URI.parse(proxy_uri)
|
proxy_uri = URI.parse(proxy_uri)
|
||||||
name = 'no_proxy'
|
name = 'no_proxy'
|
||||||
if no_proxy = ENV[name] || ENV[name.upcase]
|
if no_proxy = ENV[name] || ENV[name.upcase]
|
||||||
|
|
Loading…
Reference in a new issue