MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / download_server

Method download_server

rb/lib/selenium/server.rb:138–162  ·  view source on GitHub ↗
(uri, destination)

Source from the content-addressed store, hash-verified

136 end
137
138 def download_server(uri, destination)
139 net_http_start('github-releases.githubusercontent.com') do |http|
140 request = Net::HTTP::Get.new uri
141 resp = http.request(request) do |response|
142 total = response.content_length
143 progress = 0
144 segment_count = 0
145
146 response.read_body do |segment|
147 progress += segment.length
148 segment_count += 1
149
150 if (segment_count % 15).zero?
151 percent = progress.fdiv(total) * 100
152 print "#{CL_RESET}Downloading #{destination.path}: #{percent.to_i}% (#{progress} / #{total})"
153 segment_count = 0
154 end
155
156 destination.write(segment)
157 end
158 end
159
160 raise Error, "#{resp.code} for #{destination.path}" unless resp.is_a? Net::HTTPSuccess
161 end
162 end
163 end
164
165 #

Callers

nothing calls this directly

Calls 6

codeMethod · 0.80
lengthMethod · 0.65
newMethod · 0.45
requestMethod · 0.45
pathMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected