summaryrefslogtreecommitdiff
path: root/lib/chef/http.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/http.rb')
-rw-r--r--lib/chef/http.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index 5e52337aff..0e0bc2988e 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -196,14 +196,18 @@ class Chef
def http_client(base_url=nil)
base_url ||= url
- BasicClient.new(base_url)
+ if chef_zero_uri?(base_url)
+ SocketlessChefZeroClient.new(base_url)
+ else
+ BasicClient.new(base_url, :ssl_policy => Chef::HTTP::APISSLPolicy)
+ end
end
protected
def create_url(path)
return path if path.is_a?(URI)
- if path =~ /^(http|https):\/\//i
+ if path =~ /^(http|https|chefzero):\/\//i
URI.parse(path)
elsif path.nil? or path.empty?
URI.parse(@url)
@@ -351,6 +355,11 @@ class Chef
private
+ def chef_zero_uri?(uri)
+ uri = URI.parse(uri) unless uri.respond_to?(:scheme)
+ uri.scheme == "chefzero"
+ end
+
def redirected_to(response)
return nil unless response.kind_of?(Net::HTTPRedirection)
# Net::HTTPNotModified is undesired subclass of Net::HTTPRedirection so test for this