29#ifndef A11_NET_HTTP_DOWNLOAD_H_
30#define A11_NET_HTTP_DOWNLOAD_H_
35#include <absl/status/statusor.h>
64absl::StatusOr<std::string>
FileSha1(
const std::filesystem::path&
path);
Shared handle to one asynchronous result.
Definition future.h:126
One-shot HTTP requests by URL, with redirects and a streaming sink.
Completion values used by every asynchronous A11 operation.
std::string path
Definition main.cc:133
absl::StatusOr< std::string > FileSha1(const std::filesystem::path &path)
Computes the SHA-1 of a file, as lowercase hex.
Definition download.cc:186
std::function< void(std::uint64_t bytes_done, std::uint64_t bytes_total)> OnFetchProgress
Called as a body arrives.
Definition fetch.h:58
a11::Future< std::filesystem::path > Download(std::string url, DownloadOptions options)
Downloads url to options.destination, verified and atomically.
Definition download.cc:216
Where a download goes, and what proves it arrived intact.
Definition download.h:43
std::filesystem::path destination
Final path; parents are created.
Definition download.h:44
std::string expected_sha1
Expected SHA-1 as hex, or empty to skip verification.
Definition download.h:50
FetchOptions fetch
Request settings; see FetchOptions.
Definition download.h:52
OnFetchProgress on_progress
Optional progress callback.
Definition download.h:51
What to request, and how hard to try.
Definition fetch.h:69