Skip to content

Commit

Permalink
Skip progress report when Content-Length is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
eagletmt committed Sep 3, 2018
1 parent 82af422 commit a9fd589
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/mini_portile2/mini_portile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,14 @@ def download_file_http(url, full_path, count = 3)
"Accept-Encoding" => 'identity',
:content_length_proc => lambda{|length| total = length },
:progress_proc => lambda{|bytes|
new_progress = (bytes * 100) / total
message "\rDownloading %s (%3d%%) " % [filename, new_progress]
progress = new_progress
if total
new_progress = (bytes * 100) / total
message "\rDownloading %s (%3d%%) " % [filename, new_progress]
progress = new_progress
else
# Content-Length is unavailable because Transfer-Encoding is chunked
message "\rDownloading %s " % [filename]
end
}
}
proxy_uri = URI.parse(url).scheme.downcase == 'https' ?
Expand Down

0 comments on commit a9fd589

Please sign in to comment.