From d17661e30c1e08a14d17dcfa6ce46f81086fc1ec Mon Sep 17 00:00:00 2001 From: Thom May Date: Tue, 9 Feb 2016 14:20:35 -0800 Subject: Ensure we do streaming requests correctly everywhere --- lib/chef/cookbook/remote_file_vendor.rb | 2 +- lib/chef/knife/cookbook_show.rb | 2 +- spec/unit/knife/cookbook_show_spec.rb | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/chef/cookbook/remote_file_vendor.rb b/lib/chef/cookbook/remote_file_vendor.rb index 9155162c4c..e63d094dc4 100644 --- a/lib/chef/cookbook/remote_file_vendor.rb +++ b/lib/chef/cookbook/remote_file_vendor.rb @@ -63,7 +63,7 @@ class Chef # (remote, per manifest), do the update. This will also execute if there # is no current checksum. if current_checksum != found_manifest_record["checksum"] - raw_file = @rest.get(found_manifest_record[:url], true) + raw_file = @rest.streaming_request(found_manifest_record[:url]) Chef::Log.debug("Storing updated #{cache_filename} in the cache.") Chef::FileCache.move_to(raw_file.path, cache_filename) diff --git a/lib/chef/knife/cookbook_show.rb b/lib/chef/knife/cookbook_show.rb index 20013cea4b..5fab7c303f 100644 --- a/lib/chef/knife/cookbook_show.rb +++ b/lib/chef/knife/cookbook_show.rb @@ -69,7 +69,7 @@ class Chef cookbook = rest.get("cookbooks/#{cookbook_name}/#{cookbook_version}") manifest_entry = cookbook.preferred_manifest_record(node, segment, filename) - temp_file = rest.get(manifest_entry[:url], true) + temp_file = rest.streaming_request(manifest_entry[:url]) # the temp file is cleaned up elsewhere temp_file.open if temp_file.closed? diff --git a/spec/unit/knife/cookbook_show_spec.rb b/spec/unit/knife/cookbook_show_spec.rb index de6d569e1d..0183577ec1 100644 --- a/spec/unit/knife/cookbook_show_spec.rb +++ b/spec/unit/knife/cookbook_show_spec.rb @@ -126,7 +126,7 @@ describe Chef::Knife::CookbookShow do it "should print the raw result of the request (likely a file!)" do expect(@rest).to receive(:get).with("cookbooks/cookbook_name/0.1.0").and_return(@cookbook_response) - expect(@rest).to receive(:get).with("http://example.org/files/default.rb", true).and_return(StringIO.new(@response)) + expect(@rest).to receive(:streaming_request).with("http://example.org/files/default.rb").and_return(StringIO.new(@response)) expect(@knife).to receive(:pretty_print).with(@response) @knife.run end @@ -178,7 +178,7 @@ describe Chef::Knife::CookbookShow do @knife.config[:platform_version] = "1.0" @knife.config[:fqdn] = "examplehost.example.org" expect(@rest).to receive(:get).with("cookbooks/cookbook_name/0.1.0").and_return(@cookbook_response) - expect(@rest).to receive(:get).with("http://example.org/files/1111", true).and_return(StringIO.new(@response)) + expect(@rest).to receive(:streaming_request).with("http://example.org/files/1111").and_return(StringIO.new(@response)) expect(@knife).to receive(:pretty_print).with(@response) @knife.run end @@ -190,7 +190,7 @@ describe Chef::Knife::CookbookShow do @knife.config[:platform_version] = "1.0" @knife.config[:fqdn] = "differenthost.example.org" expect(@rest).to receive(:get).with("cookbooks/cookbook_name/0.1.0").and_return(@cookbook_response) - expect(@rest).to receive(:get).with("http://example.org/files/3333", true).and_return(StringIO.new(@response)) + expect(@rest).to receive(:streaming_request).with("http://example.org/files/3333").and_return(StringIO.new(@response)) expect(@knife).to receive(:pretty_print).with(@response) @knife.run end @@ -202,7 +202,7 @@ describe Chef::Knife::CookbookShow do @knife.config[:platform_version] = "9.10" @knife.config[:fqdn] = "differenthost.example.org" expect(@rest).to receive(:get).with("cookbooks/cookbook_name/0.1.0").and_return(@cookbook_response) - expect(@rest).to receive(:get).with("http://example.org/files/2222", true).and_return(StringIO.new(@response)) + expect(@rest).to receive(:streaming_request).with("http://example.org/files/2222").and_return(StringIO.new(@response)) expect(@knife).to receive(:pretty_print).with(@response) @knife.run end @@ -211,7 +211,7 @@ describe Chef::Knife::CookbookShow do describe "with none of the arguments, it should use the default" do it "should pass them all" do expect(@rest).to receive(:get).with("cookbooks/cookbook_name/0.1.0").and_return(@cookbook_response) - expect(@rest).to receive(:get).with("http://example.org/files/4444", true).and_return(StringIO.new(@response)) + expect(@rest).to receive(:streaming_request).with("http://example.org/files/4444").and_return(StringIO.new(@response)) expect(@knife).to receive(:pretty_print).with(@response) @knife.run end -- cgit v1.2.1