Commit b3983fbb authored by danielsdeleo's avatar danielsdeleo
Browse files

Merge branch 's3-auth-regression-fix' into 10-stable

parents fe1fd66b 8f65963c
......@@ -447,7 +447,7 @@ class Chef
headers = @default_headers.merge(headers)
#headers['Accept'] = "application/json" unless raw
headers['Accept'] = "application/json" unless raw
headers["Content-Type"] = 'application/json' if json_body
headers["Content-Type"] = 'application/json' if json_body && !headers.keys.map(&:downcase).include?("content-type")
headers['Content-Length'] = json_body.bytesize.to_s if json_body
headers[RESTRequest::ACCEPT_ENCODING] = RESTRequest::ENCODING_GZIP_DEFLATE unless gzip_disabled?
headers.merge!(authentication_headers(method, url, json_body)) if sign_requests?
......
......@@ -423,6 +423,36 @@ describe Chef::REST do
@rest.api_request(:GET, @url, {}).should == {"ohai2u"=>"json_api"}
end
context "when sending a request with a body and the content-type isn't JSON" do
let(:expected_headers) do
@base_headers.merge("content-type" => 'application/x-binary', 'Content-Length' => '13')
end
let(:request_headers) do
{"content-type" => 'application/x-binary'}
end
let(:request_body) do
Chef::JSONCompat.to_json({:one=>:two})
end
it "should build a new HTTP POST request" do
request = Net::HTTP::Post.new(@url.path)
Net::HTTP::Post.should_receive(:new).with("/?foo=bar", expected_headers).and_return(request)
@rest.raw_http_request(:POST, @url, request_headers, request_body)
request.body.should == '{"one":"two"}'
end
it "should build a new HTTP PUT request" do
request = Net::HTTP::Put.new(@url.path)
Net::HTTP::Put.should_receive(:new).with("/?foo=bar",expected_headers).and_return(request)
@rest.raw_http_request(:PUT, @url, request_headers, request_body)
request.body.should == '{"one":"two"}'
end
end
describe "when the server returns a redirect response" do
let(:redirected_url) { "https://chef.example.com:8443/foo" }
let(:redirected_uri) { URI.parse(redirected_url) }
......
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