33 std::filesystem::path
dest;
53 constexpr int kConnectTimeoutSeconds = 15;
54 return request_timeout_seconds > 0
55 ? (request_timeout_seconds < kConnectTimeoutSeconds
56 ? request_timeout_seconds
57 : kConnectTimeoutSeconds)
58 : kConnectTimeoutSeconds;
64 std::filesystem::path
path;
88 const std::string& current_path,
const std::string& location);
100 const CancelToken* cancel =
nullptr);
Definition generated_event_source.hpp:33
int download_connect_timeout_seconds(int request_timeout_seconds)
Connect-phase timeout (seconds) the downloader applies for a given request timeout_seconds.
Definition model_download.hpp:52
ResolvedRedirect resolve_redirect(const std::string ¤t_scheme_host_port, const std::string ¤t_path, const std::string &location)
Resolve an absolute, host-absolute, or path-relative redirect location against the current origin + p...
std::function< bool(const DownloadProgress &)> DownloadProgressFn
Progress callback. Return false to cancel the in-flight download.
Definition model_download.hpp:91
DownloadResult download_file(const DownloadRequest &request, const DownloadProgressFn &on_progress={}, const CancelToken *cancel=nullptr)
Blocking streaming download.
Definition model_download.hpp:21
std::uint64_t total
Total expected bytes, or 0 if the server didn't say.
Definition model_download.hpp:23
std::uint64_t downloaded
Bytes written so far (includes resumed bytes).
Definition model_download.hpp:22
Definition model_download.hpp:31
std::vector< HttpHeader > headers
Extra request headers (e.g. Authorization).
Definition model_download.hpp:35
int timeout_seconds
0 ⇒ a sensible library default.
Definition model_download.hpp:37
std::filesystem::path dest
Final destination path.
Definition model_download.hpp:33
std::string expected_sha256
Hex digest the finished file must match.
Definition model_download.hpp:34
bool resume
Resume from a prior partial <dest>.part via Range.
Definition model_download.hpp:36
bool allow_unverified
An empty expected_sha256 means nothing can vouch for the bytes, so the download is refused (DownloadR...
Definition model_download.hpp:41
std::string url
http(s)://… (resolve hf:// first).
Definition model_download.hpp:32
Definition model_download.hpp:61
std::uint64_t bytes
Total bytes of the finished file.
Definition model_download.hpp:65
std::string error
Definition model_download.hpp:63
bool unverified
The request carried no expected digest.
Definition model_download.hpp:72
bool ok
Definition model_download.hpp:62
bool cancelled
Stopped via callback / token (partial kept for resume).
Definition model_download.hpp:68
bool resumed
A prior partial was continued.
Definition model_download.hpp:67
std::string sha256
Hex digest of the finished file.
Definition model_download.hpp:66
std::filesystem::path path
The finished file (== request.dest) on success.
Definition model_download.hpp:64
A redirect Location resolved against the request it answered.
Definition model_download.hpp:76
std::string scheme_host_port
e.g. "https://cdn.example.com:8443"
Definition model_download.hpp:77
std::string path
Absolute path on that origin.
Definition model_download.hpp:78
std::string error
Definition model_download.hpp:80
bool ok
False when unresolvable or refused; see error.
Definition model_download.hpp:79