Commit 93901762 authored by sdelano's avatar sdelano
Browse files

Merge branch 'CHEF-2189' into 0.9-stable

parents 3abf9d97 a81552fd
......@@ -359,6 +359,7 @@ class Chef
headers["Content-Type"] = 'application/json' if json_body
headers['Content-Length'] = json_body.bytesize.to_s if json_body
headers.merge!(authentication_headers(method, url, json_body)) if sign_requests?
headers.merge!(Chef::Config[:custom_http_headers]) if Chef::Config[:custom_http_headers]
headers
end
......
......@@ -304,6 +304,27 @@ describe Chef::REST do
@rest.api_request(:GET, @url, {})
end
context "when configured with custom http headers" do
before(:each) do
@custom_headers = {
'X-Custom-ChefSecret' => 'sharpknives',
'X-Custom-RequestPriority' => 'extremely low'
}
Chef::Config[:custom_http_headers] = @custom_headers
end
after(:each) do
Chef::Config[:custom_http_headers] = nil
end
it "should set them on the http request" do
url_string = an_instance_of(String)
header_hash = hash_including(@custom_headers)
Net::HTTP::Get.should_receive(:new).with(url_string, header_hash)
@rest.api_request(:GET, @url, {})
end
end
it "should set the cookie for this request if one exists for the given host:port" do
Chef::REST::CookieJar.instance["#{@url.host}:#{@url.port}"] = "cookie monster"
Net::HTTP::Get.should_receive(:new).with("/?foo=bar",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment