Method: Grubby#get_mirrored
- Defined in:
- lib/grubby.rb
#get_mirrored(mirror_uris, parameters = [], referer = nil, headers = {}) ⇒ Mechanize::Page, ...
Calls #get
with each of mirror_uris
until a successful (“200 OK”) response is received, and returns that #get
result. Rescues and logs Mechanize::ResponseCodeError
failures for all but the last mirror.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/grubby.rb', line 132 def get_mirrored(mirror_uris, parameters = [], referer = nil, headers = {}) i = 0 begin get(mirror_uris[i], parameters, referer, headers) rescue Mechanize::ResponseCodeError => e i += 1 if i >= mirror_uris.length raise else $log.debug("Mirror failed (code #{e.response_code}): #{mirror_uris[i - 1]}") $log.debug("Try mirror: #{mirror_uris[i]}") retry end end end |