diff options
-rw-r--r-- | lib/chef/http.rb | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb index 3e69f58383..00b13482a1 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -227,20 +227,23 @@ class Chef end def http_client(base_url = nil) - base_url ||= url - if chef_zero_uri?(base_url) - # PERFORMANCE CRITICAL: *MUST* lazy require here otherwise we load up webrick - # via chef-zero and that hits DNS (at *require* time) which may timeout, - # when for most knife/chef-client work we never need/want this loaded. - - unless defined?(SocketlessChefZeroClient) - require "chef/http/socketless_chef_zero_client" - end + @http_client = + begin + base_url ||= url + if chef_zero_uri?(base_url) + # PERFORMANCE CRITICAL: *MUST* lazy require here otherwise we load up webrick + # via chef-zero and that hits DNS (at *require* time) which may timeout, + # when for most knife/chef-client work we never need/want this loaded. + + unless defined?(SocketlessChefZeroClient) + require "chef/http/socketless_chef_zero_client" + end - SocketlessChefZeroClient.new(base_url) - else - BasicClient.new(base_url, :ssl_policy => Chef::HTTP::APISSLPolicy) - end + SocketlessChefZeroClient.new(base_url) + else + BasicClient.new(base_url, :ssl_policy => Chef::HTTP::APISSLPolicy) + end + end end protected |