- url = choice(locations)
- parsed = urlparse(url)
- assert(parsed[0] == "http", "Only HTTP is supported, not '%s'" % parsed[0])
- host = parsed[1]
- path = urlunparse(('', '') + parsed[2:])
-
- # Make sure a port is included for consistency
- if host.find(':') >= 0:
- host, port = host.split(':', 1)
- port = int(port)
+ if peers:
+ peer = choice(peers)
+ log.msg('Downloading from peer %s' % peer)
+ host, port = splitHostPort('http', peer)
+ path = '/~/' + quote_plus(hash.expected())