summaryrefslogtreecommitdiff
path: root/lib/soap/netHttpClient.rb
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-04 08:57:11 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-04 08:57:11 +0000
commitcbef5b65dbbb89fe560fcc56a67d0ff1d40b5510 (patch)
tree53945ffb7e022f9171e0b46fc55aa62d43c75934 /lib/soap/netHttpClient.rb
parent94e01ab6450beda3ae5d5ed2c7f779477b475bfe (diff)
* lib/soap/netHttpClient.rb: follow http-access2. hosts which matches
ENV['no_proxy'] or ENV['NO_PROXY'] is not proxyed. - [,:] separated. ("ruby-lang.org:rubyist.net") - no regexp. (give "ruby-lang.org", not "*.ruby-lang.org") - if you want specify hot by IP address, give full address. ("192.168.1.1, 192.168.1.2") * lib/soap/rpc/cgistub.rb: return "Status: XXX MMM" line. * test/runner.rb: give testsuite name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/soap/netHttpClient.rb')
-rw-r--r--lib/soap/netHttpClient.rb28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/soap/netHttpClient.rb b/lib/soap/netHttpClient.rb
index 14003b34d0..60fb146ec1 100644
--- a/lib/soap/netHttpClient.rb
+++ b/lib/soap/netHttpClient.rb
@@ -26,6 +26,7 @@ module SOAP
class NetHttpClient
attr_accessor :proxy
+ attr_accessor :no_proxy
attr_accessor :debug_dev
attr_reader :session_manager
@@ -54,6 +55,8 @@ class NetHttpClient
@agent = agent
@debug_dev = nil
@session_manager = SessionManager.new
+ name = 'no_proxy'
+ @no_proxy = ENV[name] || ENV[name.upcase]
end
def reset(url)
@@ -83,8 +86,11 @@ class NetHttpClient
private
def start(url)
- proxy_host = @proxy ? @proxy.host : nil
- proxy_port = @proxy ? @proxy.port : nil
+ proxy_host = proxy_port = nil
+ unless no_proxy?(url)
+ proxy_host = @proxy.host
+ proxy_port = @proxy.port
+ end
response = nil
Net::HTTP::Proxy(proxy_host, proxy_port).start(url.host, url.port) { |http|
if http.respond_to?(:set_debug_output)
@@ -95,6 +101,24 @@ private
}
response
end
+
+ NO_PROXY_HOSTS = ['localhost']
+
+ def no_proxy?(uri)
+ if !@proxy or NO_PROXY_HOSTS.include?(uri.host)
+ return true
+ end
+ if @no_proxy
+ @no_proxy.scan(/([^:,]*)(?::(\d+))?/) do |host, port|
+ if /(\A|\.)#{Regexp.quote(host)}\z/i =~ uri.host &&
+ (!port || uri.port == port.to_i)
+ return true
+ end
+ end
+ else
+ false
+ end
+ end
end