summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2016-02-09 14:01:12 -0800
committerThom May <thom@chef.io>2016-02-09 14:01:12 -0800
commitb4b91836f0b2f0e09e089acab43e410cd73e48a4 (patch)
treec6aadeaef06102b0f92d7bde5c0656191cba6b21
parent7755b93c72ef33d5041b6a9c4b53bcf29814579d (diff)
downloadchef-b4b91836f0b2f0e09e089acab43e410cd73e48a4.tar.gz
Use a streaming request to download cookbook
fixes #4549
-rw-r--r--lib/chef/knife/cookbook_site_download.rb3
-rw-r--r--spec/unit/knife/cookbook_site_download_spec.rb10
2 files changed, 5 insertions, 8 deletions
diff --git a/lib/chef/knife/cookbook_site_download.rb b/lib/chef/knife/cookbook_site_download.rb
index 7e4eda015f..2bdeea9781 100644
--- a/lib/chef/knife/cookbook_site_download.rb
+++ b/lib/chef/knife/cookbook_site_download.rb
@@ -86,8 +86,7 @@ class Chef
def download_cookbook
ui.info "Downloading #{@name_args[0]} from Supermarket at version #{version} to #{download_location}"
- noauth_rest.sign_on_redirect = false
- tf = noauth_rest.get desired_cookbook_data["file"], true
+ tf = noauth_rest.streaming_request(desired_cookbook_data["file"])
::FileUtils.cp tf.path, download_location
ui.info "Cookbook saved: #{download_location}"
diff --git a/spec/unit/knife/cookbook_site_download_spec.rb b/spec/unit/knife/cookbook_site_download_spec.rb
index 663ad1af74..d7f26f2f2e 100644
--- a/spec/unit/knife/cookbook_site_download_spec.rb
+++ b/spec/unit/knife/cookbook_site_download_spec.rb
@@ -60,8 +60,6 @@ describe Chef::Knife::CookbookSiteDownload do
"file" => "http://example.com/apache2_#{@version_us}.tgz" }
@temp_file = double( :path => "/tmp/apache2_#{@version_us}.tgz" )
@file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz")
-
- expect(@noauth_rest).to receive(:sign_on_redirect=).with(false)
end
context "downloading the latest version" do
@@ -69,8 +67,8 @@ describe Chef::Knife::CookbookSiteDownload do
expect(@noauth_rest).to receive(:get).
with(@current_data["latest_version"]).
and_return(@cookbook_data)
- expect(@noauth_rest).to receive(:get).
- with(@cookbook_data["file"], true).
+ expect(@noauth_rest).to receive(:streaming_request).
+ with(@cookbook_data["file"]).
and_return(@temp_file)
end
@@ -134,8 +132,8 @@ describe Chef::Knife::CookbookSiteDownload do
expect(@noauth_rest).to receive(:get).
with("#{@cookbook_api_url}/apache2/versions/#{@version_us}").
and_return(@cookbook_data)
- expect(@noauth_rest).to receive(:get).
- with(@cookbook_data["file"], true).
+ expect(@noauth_rest).to receive(:streaming_request).
+ with(@cookbook_data["file"]).
and_return(@temp_file)
expect(FileUtils).to receive(:cp).with(@temp_file.path, @file)
@knife.run