mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 01:26:15 +02:00
Merge pull request #3981 from domenkozar/http-binary-cache-allow-absolute-urls
Allow HTTP binary cache to request absolute uris
This commit is contained in:
commit
14652da432
1 changed files with 7 additions and 4 deletions
|
@ -85,7 +85,7 @@ protected:
|
||||||
checkEnabled();
|
checkEnabled();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileTransferRequest request(cacheUri + "/" + path);
|
FileTransferRequest request(makeRequest(path));
|
||||||
request.head = true;
|
request.head = true;
|
||||||
getFileTransfer()->download(request);
|
getFileTransfer()->download(request);
|
||||||
return true;
|
return true;
|
||||||
|
@ -103,7 +103,7 @@ protected:
|
||||||
std::shared_ptr<std::basic_iostream<char>> istream,
|
std::shared_ptr<std::basic_iostream<char>> istream,
|
||||||
const std::string & mimeType) override
|
const std::string & mimeType) override
|
||||||
{
|
{
|
||||||
auto req = FileTransferRequest(cacheUri + "/" + path);
|
auto req = makeRequest(path);
|
||||||
req.data = std::make_shared<string>(StreamToSourceAdapter(istream).drain());
|
req.data = std::make_shared<string>(StreamToSourceAdapter(istream).drain());
|
||||||
req.mimeType = mimeType;
|
req.mimeType = mimeType;
|
||||||
try {
|
try {
|
||||||
|
@ -115,8 +115,11 @@ protected:
|
||||||
|
|
||||||
FileTransferRequest makeRequest(const std::string & path)
|
FileTransferRequest makeRequest(const std::string & path)
|
||||||
{
|
{
|
||||||
FileTransferRequest request(cacheUri + "/" + path);
|
return FileTransferRequest(
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue