diff options
author | Brandon Raabe <brandocorp@gmail.com> | 2015-03-15 16:19:37 -0700 |
---|---|---|
committer | Brandon Raabe <brandocorp@gmail.com> | 2015-03-15 16:19:37 -0700 |
commit | 8af291b0e7cc4569eb28f09b68df4998332c9aa8 (patch) | |
tree | 0be92bdace581c180a61ba447cf60c367fe679fb | |
parent | 3ad167ec10e6374e645be74da1cc2f0b744f1aa6 (diff) | |
download | chef-8af291b0e7cc4569eb28f09b68df4998332c9aa8.tar.gz |
read content length from the response and use to show overall status
-rw-r--r-- | lib/chef/http.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb index 5e52337aff..376a61d7a2 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -73,7 +73,7 @@ class Chef attr_reader :url attr_reader :sign_on_redirect attr_reader :redirect_limit - + attr_reader :show_progress attr_reader :middlewares # Create a HTTP client object. The supplied +url+ is used as the base for @@ -86,6 +86,7 @@ class Chef @sign_on_redirect = true @redirects_followed = 0 @redirect_limit = 10 + @show_progress = options[:show_progress] || false @middlewares = [] self.class.middlewares.each do |middleware_class| @@ -366,6 +367,7 @@ class Chef end def stream_to_tempfile(url, response) + total = response['Content-Length'] tf = Tempfile.open("chef-rest") if Chef::Platform.windows? tf.binmode # required for binary files on Windows platforms @@ -378,6 +380,7 @@ class Chef response.read_body do |chunk| tf.write(stream_handler.handle_chunk(chunk)) + Chef::Log.info("#{tf.size} / #{total}") if show_progress end tf.close tf |