aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorDomen Kožar <domen@dev.si>2020-09-01 16:41:42 +0200
committerDomen Kožar <domen@dev.si>2020-09-01 21:35:48 +0200
commitdd4b56c87f8989c2d31a78b6c12cc2b1e3991fe2 (patch)
tree9e81ad3bedec90b789556035a7b0b66f4acb9e74 /src/libstore
parent6d7f7efb896c482ff6e7ce6c105e4dd3f7ee7218 (diff)
Allow HTTP binary cache to request absolute uris
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/http-binary-cache-store.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc
index c1ceb08cf..1733239fb 100644
--- a/src/libstore/http-binary-cache-store.cc
+++ b/src/libstore/http-binary-cache-store.cc
@@ -85,7 +85,7 @@ protected:
checkEnabled();
try {
- FileTransferRequest request(cacheUri + "/" + path);
+ FileTransferRequest request(makeRequest(path));
request.head = true;
getFileTransfer()->download(request);
return true;
@@ -103,7 +103,7 @@ protected:
std::shared_ptr<std::basic_iostream<char>> istream,
const std::string & mimeType) override
{
- auto req = FileTransferRequest(cacheUri + "/" + path);
+ auto req = makeRequest(path);
req.data = std::make_shared<string>(StreamToSourceAdapter(istream).drain());
req.mimeType = mimeType;
try {
@@ -115,8 +115,11 @@ protected:
FileTransferRequest makeRequest(const std::string & path)
{
- FileTransferRequest request(cacheUri + "/" + path);
- return request;
+ return FileTransferRequest(
+ hasPrefix(path, "https://") || hasPrefix(path, "http://") || hasPrefix(path, "file://")
+ ? path
+ : cacheUri + "/" + path);
+
}
void getFile(const std::string & path, Sink & sink) override