summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-11-25 08:53:42 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-11-25 08:53:42 +0000
commita3388b68b7d2babce3d696cacb3e4cbfcd898490 (patch)
treeff68bb98677f94b9beac6fc0d5f3aeec9b639089
parentf1d89b24da13a8161a53ebe8bb20ce438fc86898 (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--lib/open-uri.rb33
2 files changed, 31 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index a9b71760b37..f542abfce91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* test/wsdl/multiplefault.wsdl, test/wsdl/test_multiplefault.rb:
diff --git a/lib/open-uri.rb b/lib/open-uri.rb
index 5aaa5c4f9c4..168bc0a76d9 100644
--- a/lib/open-uri.rb
+++ b/lib/open-uri.rb
@@ -443,16 +443,35 @@ module URI
# ftp_proxy, no_proxy, etc.
# If there is no proper proxy, nil is returned.
#
- # The enveironment variable CGI_http_proxy and CGI_HTTP_PROXY is used
- # instead of http_proxy and HTTP_PROXY in the CGI environment because
- # HTTP_PROXY can be set by Proxy: header sent by a CGI client.
+ # Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.)
+ # are examined too.
+ #
+ # 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
name = self.scheme.downcase + '_proxy'
- if ENV.include? 'REQUEST_METHOD' # in CGI?
- # Use CGI_HTTP_PROXY. cf. libwww-perl.
- name = "CGI_#{name}" if /\Ahttp_/i =~ name
+ proxy_uri = nil
+ if name == 'http_proxy' && ENV.include?('REQUEST_METHOD') # CGI?
+ # 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
- if proxy_uri = ENV[name] || ENV[name.upcase]
+
+ if proxy_uri
proxy_uri = URI.parse(proxy_uri)
name = 'no_proxy'
if no_proxy = ENV[name] || ENV[name.upcase]