Skip to content

Commit

Permalink
Allow HTTP binary cache to request absolute uris
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Dec 16, 2020
1 parent 359c07b commit 6de15f7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/libstore/http-binary-cache-store.cc
Expand Up @@ -82,7 +82,7 @@ class HttpBinaryCacheStore : public BinaryCacheStore
checkEnabled();

try {
DownloadRequest request(cacheUri + "/" + path);
DownloadRequest request(makeRequest(path));
request.head = true;
getDownloader()->download(request);
return true;
Expand All @@ -100,7 +100,7 @@ class HttpBinaryCacheStore : public BinaryCacheStore
const std::string & data,
const std::string & mimeType) override
{
auto req = DownloadRequest(cacheUri + "/" + path);
auto req = makeRequest(path);
req.data = std::make_shared<string>(data); // FIXME: inefficient
req.mimeType = mimeType;
try {
Expand All @@ -112,8 +112,10 @@ class HttpBinaryCacheStore : public BinaryCacheStore

DownloadRequest makeRequest(const std::string & path)
{
DownloadRequest request(cacheUri + "/" + path);
return request;
return DownloadRequest(
hasPrefix(path, "https://") || hasPrefix(path, "http://") || hasPrefix(path, "file://")
? path
: cacheUri + "/" + path);
}

void getFile(const std::string & path, Sink & sink) override
Expand Down

0 comments on commit 6de15f7

Please sign in to comment.