Skip to content

Commit

Permalink
Merge pull request #86 from eagletmt/skip-progress-when-chunked
Browse files Browse the repository at this point in the history
Skip progress report when Content-Length is unavailable
  • Loading branch information
flavorjones committed Dec 2, 2018
2 parents 51f5ac4 + a9fd589 commit ce0e270
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 ce0e270

Please sign in to comment.