class Selenium::Server

def download_server(uri, destination)

def download_server(uri, destination)
  net_http_start('github-releases.githubusercontent.com') do |http|
    request = Net::HTTP::Get.new uri
    resp = http.request(request) do |response|
      total = response.content_length
      progress = 0
      segment_count = 0
      response.read_body do |segment|
        progress += segment.length
        segment_count += 1
        if (segment_count % 15).zero?
          percent = progress.fdiv(total) * 100
          print "#{CL_RESET}Downloading #{destination.path}: #{percent.to_i}% (#{progress} / #{total})"
          segment_count = 0
        end
        destination.write(segment)
      end
    end
    raise Error, "#{resp.code} for #{destination.path}" unless resp.is_a? Net::HTTPSuccess
  end
end