Method: Chef::HTTP::BasicClient#build_http_client

Defined in:
lib/chef/http/basic_client.rb

#build_http_clientObject



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/chef/http/basic_client.rb', line 110

def build_http_client
  # Note: the last nil in the new below forces Net::HTTP to ignore the
  # no_proxy environment variable. This is a workaround for limitations
  # in Net::HTTP use of the no_proxy environment variable. We internally
  # match no_proxy with a fuzzy matcher, rather than letting Net::HTTP
  # do it.
  http_client = http_client_builder.new(host, port, nil)
  http_client.proxy_port = nil if http_client.proxy_address.nil?

  if url.scheme == HTTPS
    configure_ssl(http_client)
  end

  opts = nethttp_opts.dup
  opts["read_timeout"] ||= config[:rest_timeout]
  opts["open_timeout"] ||= config[:rest_timeout]

  opts.each do |key, value|
    http_client.send(:"#{key}=", value)
  end

  if keepalives
    http_client.start
  else
    http_client
  end
end