Method: Chef::HTTP#http_client
- Defined in:
- lib/chef/http.rb
#http_client(base_url = nil) ⇒ Object
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/chef/http.rb', line 264 def http_client(base_url = nil) base_url ||= url if keepalives && !base_url.nil? # only reuse the http_client if we want keepalives and have a base_url @http_client ||= {} # the per-host per-port cache here gets persistent connections correct when # redirecting to different servers if base_url.is_a?(String) # sigh, this kind of abuse can't happen with strongly typed languages @http_client[base_url] ||= build_http_client(base_url) else @http_client[base_url.host] ||= {} @http_client[base_url.host][base_url.port] ||= build_http_client(base_url) end else build_http_client(base_url) end end |