about summary refs log blame commit diff
path: root/src/libstore/download.hh
blob: 5dd2d2c82deca4e991e694a3f6817d040d849357 (plain) (tree)
1
2
3
4
5
6
7
8


                   
 



                 



                         

                                                  

  





                      
            
 







                                                                                     
 
                                 
 







                                                                     
 

                             
 
#pragma once

#include "types.hh"

#include <string>

namespace nix {

struct DownloadOptions
{
    string expectedETag;
    bool verifyTLS{true};
    enum { yes, no, automatic } showProgress{yes};
    bool head{false};
};

struct DownloadResult
{
    bool cached;
    string data, etag;
};

class Store;

struct Downloader
{
    virtual DownloadResult download(string url, const DownloadOptions & options) = 0;

    Path downloadCached(ref<Store> store, const string & url, bool unpack);

    enum Error { NotFound, Forbidden, Misc };
};

ref<Downloader> makeDownloader();

class DownloadError : public Error
{
public:
    Downloader::Error error;
    DownloadError(Downloader::Error error, const FormatOrString & fs)
        : Error(fs), error(error)
    { }
};

bool isUri(const string & s);

}