A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
download.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 The A11 Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
29#ifndef A11_NET_HTTP_DOWNLOAD_H_
30#define A11_NET_HTTP_DOWNLOAD_H_
31
32#include <filesystem>
33#include <string>
34
35#include <absl/status/statusor.h>
36
38#include "a11/net/http/fetch.h"
39
40namespace a11::net {
41
54
64absl::StatusOr<std::string> FileSha1(const std::filesystem::path& path);
65
81 DownloadOptions options);
82
83} // namespace a11::net
84
85#endif // A11_NET_HTTP_DOWNLOAD_H_
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
Definition action.h:65
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