From 3b156079b3bd591404d484a28d7ce7712207914b Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Tue, 3 Nov 2015 10:28:04 -0800 Subject: lazy the socketless require in Chef::HTTP if this is always required then everything that uses Chef::HTTP will load up chef-zero which will load up Webrick, which does DNS lookups of the current host which causes a DNS lookup and possible timeout. it also likely isn't doing pretty things to chef-client memory usage and load times there as well. --- lib/chef/http.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/chef/http.rb b/lib/chef/http.rb index 16a826a3db..bb28ce280b 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -5,7 +5,7 @@ # Author:: Christopher Brown () # Author:: Christopher Walters () # Author:: Daniel DeLeo () -# Copyright:: Copyright (c) 2009, 2010, 2013 Opscode, Inc. +# Copyright:: Copyright (c) 2009, 2010, 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,7 +25,6 @@ require 'tempfile' require 'net/https' require 'uri' require 'chef/http/basic_client' -require 'chef/http/socketless_chef_zero_client' require 'chef/monkey_patches/net_http' require 'chef/config' require 'chef/platform/query_helpers' @@ -198,6 +197,9 @@ class Chef 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 all of + # chef-zero and webrick when we mostly never want to or have to + require 'chef/http/socketless_chef_zero_client' SocketlessChefZeroClient.new(base_url) else BasicClient.new(base_url, :ssl_policy => Chef::HTTP::APISSLPolicy) -- cgit v1.2.1