diff options
Diffstat (limited to 'lib/chef/provider/remote_file/http.rb')
-rw-r--r-- | lib/chef/provider/remote_file/http.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/chef/provider/remote_file/http.rb b/lib/chef/provider/remote_file/http.rb index 6a9738c02b..ad044f9e3c 100644 --- a/lib/chef/provider/remote_file/http.rb +++ b/lib/chef/provider/remote_file/http.rb @@ -39,6 +39,10 @@ class Chef @current_resource = current_resource end + def events + new_resource.events + end + def headers conditional_get_headers.merge(new_resource.headers) end @@ -57,7 +61,13 @@ class Chef def fetch http = Chef::HTTP::Simple.new(uri, http_client_opts) - tempfile = http.streaming_request(uri, headers) + if want_progress? + tempfile = http.streaming_request_with_progress(uri, headers) do |size, total| + events.resource_update_progress(new_resource, size, total, progress_interval) + end + else + tempfile = http.streaming_request(uri, headers) + end if tempfile update_cache_control_data(tempfile, http.last_response) tempfile.close @@ -78,6 +88,14 @@ class Chef @cache_control_data ||= CacheControlData.load_and_validate(uri, current_resource.checksum) end + def want_progress? + events.formatter? && (Chef::Config[:show_download_progress] || !!new_resource.show_progress) + end + + def progress_interval + Chef::Config[:download_progress_interval] + end + def want_mtime_cache_control? new_resource.use_last_modified end |