1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 06:53:54 +02:00

Allow HTTP binary cache to request absolute uris

This commit is contained in:
Domen Kožar 2020-12-16 14:13:15 +01:00
parent 359c07b9fd
commit 6de15f722d
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246

View file

@ -82,7 +82,7 @@ protected:
checkEnabled(); checkEnabled();
try { try {
DownloadRequest request(cacheUri + "/" + path); DownloadRequest request(makeRequest(path));
request.head = true; request.head = true;
getDownloader()->download(request); getDownloader()->download(request);
return true; return true;
@ -100,7 +100,7 @@ protected:
const std::string & data, const std::string & data,
const std::string & mimeType) override const std::string & mimeType) override
{ {
auto req = DownloadRequest(cacheUri + "/" + path); auto req = makeRequest(path);
req.data = std::make_shared<string>(data); // FIXME: inefficient req.data = std::make_shared<string>(data); // FIXME: inefficient
req.mimeType = mimeType; req.mimeType = mimeType;
try { try {
@ -112,8 +112,10 @@ protected:
DownloadRequest makeRequest(const std::string & path) DownloadRequest makeRequest(const std::string & path)
{ {
DownloadRequest request(cacheUri + "/" + path); return DownloadRequest(
return request; hasPrefix(path, "https://") || hasPrefix(path, "http://") || hasPrefix(path, "file://")
? path
: cacheUri + "/" + path);
} }
void getFile(const std::string & path, Sink & sink) override void getFile(const std::string & path, Sink & sink) override