summaryrefslogtreecommitdiff
path: root/lib/open-uri.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-11-24 11:01:57 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-11-24 11:01:57 +0000
commit087a8db4d2bf4fb6807693b1da2caadffb33702c (patch)
tree103e1e399052604de41e8bdead933b25a6dfba1a /lib/open-uri.rb
parent9421725f53a40c8ac3e7ede3e76726f59eaddd51 (diff)
* lib/open-uri.rb (URI::Generic#find_proxy): use CGI_HTTP_PROXY
instead of HTTP_PROXY in the CGI environment. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/open-uri.rb')
-rw-r--r--lib/open-uri.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/open-uri.rb b/lib/open-uri.rb
index 42503f15cf..871b7b490e 100644
--- a/lib/open-uri.rb
+++ b/lib/open-uri.rb
@@ -312,7 +312,7 @@ module OpenURI
elsif block_given?
yield
elsif type && %r{\Atext/} =~ type &&
- @base_uri && @base_uri.scheme == 'http'
+ @base_uri && /\Ahttp\z/i =~ @base_uri.scheme
"iso-8859-1" # RFC2616 3.7.1
else
nil
@@ -434,8 +434,16 @@ module URI
# The proxy URI is obtained from environment variables such as http_proxy,
# 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.
def find_proxy
- name = self.scheme + '_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
+ end
if proxy_uri = ENV[name] || ENV[name.upcase]
proxy_uri = URI.parse(proxy_uri)
name = 'no_proxy'