Support shard downloading via HTTP or HTTPS

This commit is contained in:
Devon White
2020-08-11 12:10:10 -04:00
committed by Nik Bougalis
parent a8d481c2a5
commit 2bba79138f
10 changed files with 491 additions and 101 deletions

View File

@@ -375,13 +375,17 @@ ShardArchiveHandler::next(std::lock_guard<std::mutex> const& l)
// sleeps.
auto const& url{archives_.begin()->second};
auto wrapper = jobCounter_.wrap([this, url, dstDir](Job&) {
auto const ssl = (url.scheme == "https");
auto const defaultPort = ssl ? 443 : 80;
if (!downloader_->download(
url.domain,
std::to_string(url.port.get_value_or(443)),
std::to_string(url.port.get_value_or(defaultPort)),
url.path,
11,
dstDir / "archive.tar.lz4",
[this](path dstPath) { complete(dstPath); }))
[this](path dstPath) { complete(dstPath); },
ssl))
{
std::lock_guard<std::mutex> l(m_);
removeAndProceed(l);