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



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/http_configuration.rb', line 9

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