Class: Net::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/http_configuration.rb

Defined Under Namespace

Classes: Configuration

Class Method Summary collapse

Class Method Details

.new_with_configuration(address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil) ⇒ Object Also known as: new



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/http_configuration.rb', line 35

def new_with_configuration (address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil)
  config_options = Configuration.current
  if config_options
    if Configuration.no_proxy?(address, config_options)
      p_addr = nil
      p_port = nil
      p_user = nil
      p_pass = nil
    elsif p_addr.nil? and config_options[:proxy_host]
      p_addr = config_options[:proxy_host]
      p_port = config_options[:proxy_port].to_i
      p_user = config_options[:proxy_user]
      p_pass = config_options[:proxy_password]
    end
  end
  
  http = HTTP.new_without_configuration(address, port, p_addr, p_port, p_user, p_pass)

  if config_options
    http.open_timeout = config_options[:open_timeout] if config_options[:open_timeout]
    http.read_timeout = config_options[:read_timeout] if config_options[:read_timeout]
  end

  return http
end