Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow HTTP binary cache to request absolute uris #4374

Merged
merged 1 commit into from
Dec 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/libstore/http-binary-cache-store.cc
Original file line number Diff line number Diff line change
@@ -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;
@@ -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 {
@@ -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