From 6de15f722daa709ee0ea5a32cc6b9b203d8bac4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Wed, 16 Dec 2020 14:13:15 +0100 Subject: [PATCH] Allow HTTP binary cache to request absolute uris --- src/libstore/http-binary-cache-store.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc index 779f89e68..ba8bbd78b 100644 --- a/src/libstore/http-binary-cache-store.cc +++ b/src/libstore/http-binary-cache-store.cc @@ -82,7 +82,7 @@ protected: checkEnabled(); try { - DownloadRequest request(cacheUri + "/" + path); + DownloadRequest request(makeRequest(path)); request.head = true; getDownloader()->download(request); return true; @@ -100,7 +100,7 @@ protected: const std::string & data, const std::string & mimeType) override { - auto req = DownloadRequest(cacheUri + "/" + path); + auto req = makeRequest(path); req.data = std::make_shared(data); // FIXME: inefficient req.mimeType = mimeType; try { @@ -112,8 +112,10 @@ protected: 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