summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-11-03 10:28:04 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-11-04 08:01:36 -0800
commit3b156079b3bd591404d484a28d7ce7712207914b (patch)
tree5a382ec7ecf35d1d366fca07614686868420fdcd
parent38524b661688be1c3e7b8991e8fdb55b17f60adc (diff)
downloadchef-3b156079b3bd591404d484a28d7ce7712207914b.tar.gz
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.
-rw-r--r--lib/chef/http.rb6
1 files 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 (<cb@opscode.com>)
# Author:: Christopher Walters (<cw@opscode.com>)
# Author:: Daniel DeLeo (<dan@opscode.com>)
-# 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)