Download file stop suddenly

Then please file a formal issue in the official API Issue Tracker:
Issues · SketchUp/api-issue-tracker · GitHub

Some servers do not send a total size for the resource being downloaded.
If this is the case, the total will not be more than zero (and usually == -1.)

So you can only calculate the percentage when the total is supplied.

Ex:

pattern = "Downloading: %d (%#.1f%%)"

request.set_download_progress_callback do |current, total|
  if total > 0
    percentage = ((current / total.to_f)*100).round(1)
    puts format(pattern, current, percentage)
  else
    puts "Downloading: #{current}"
  end
end

REF:


There is also a means in HTTP requests to ask the server ahead of time what size a resource is going to be. Not all servers will return the value. In this case the request is a HEAD type.

REF:

Open API Issue:

Another forum topic on this subject: