lib/http_configuration.rb in http_configuration-1.0.2 vs lib/http_configuration.rb in http_configuration-1.0.3

- old
+ new

@@ -1,36 +1,10 @@ require 'net/protocol' require 'net/http' module Net - - class Protocol - private - - # Default error type to a non-interrupt exception - def timeout (secs, errorType = NetworkTimeoutError) - super(secs, errorType) - end - - end - - class BufferedIO - - private - - # Default error type to a non-interrupt exception - def timeout (secs, errorType = NetworkTimeoutError) - super(secs, errorType) - end - - end - - # Error thrown by network timeouts - class NetworkTimeoutError < StandardError - end - class HTTP class << self def new_with_configuration (address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil) config_options = Configuration.current @@ -104,40 +78,42 @@ ensure Thread.current[:net_http_configuration].pop end end - def self.no_proxy? (host, options) - return false unless options[:no_proxy].kind_of?(Array) + class << self + def no_proxy? (host, options) + return false unless options[:no_proxy].kind_of?(Array) - host = host.downcase - options[:no_proxy].each do |pattern| - pattern = pattern.downcase - return true if host[-pattern.length, pattern.length] == pattern - end + host = host.downcase + options[:no_proxy].each do |pattern| + pattern = pattern.downcase + return true if host[-pattern.length, pattern.length] == pattern + end - return false - end + return false + end - # Set the options for a global configuration used for all HTTP requests. The global configuration can be cleared - # by setting nil - def self.set_global (options) - if options - @global = Configuration.new(options) - else - @global = nil + # Set the options for a global configuration used for all HTTP requests. The global configuration can be cleared + # by setting nil + def set_global (options) + if options + @global = Configuration.new(options) + else + @global = nil + end end - end - def self.global - @global - end + def global + @global + end - # Get the current configuration that is in scope. - def self.current - stack = Thread.current[:net_http_configuration] - config = stack.last if stack - config || global + # Get the current configuration that is in scope. + def current + stack = Thread.current[:net_http_configuration] + config = stack.last if stack + config || global + end end private def expand_proxy_config! (options) \ No newline at end of file