-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp_client.h
More file actions
35 lines (28 loc) · 978 Bytes
/
Copy pathhttp_client.h
File metadata and controls
35 lines (28 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
#include <atomic>
#include <filesystem>
#include <cstdint>
#include <functional>
#include <optional>
#include <string>
namespace mapupdater::net {
struct HttpResponse {
uint32_t status_code = 0;
std::string body;
};
struct DownloadFileResult {
bool success = false;
bool canceled = false;
uint32_t status_code = 0;
uint32_t error_code = 0;
uint64_t downloaded_bytes = 0;
uint64_t total_bytes = 0;
};
using DownloadProgressCallback = std::function<bool(uint64_t, uint64_t)>;
std::optional<HttpResponse> HttpGet(const std::wstring &url);
DownloadFileResult HttpDownloadToFile(const std::wstring &url,
const std::filesystem::path &target_path,
DownloadProgressCallback on_progress = {},
const std::atomic_bool *cancel_flag = nullptr);
std::optional<uint32_t> HttpPostNoBody(const std::wstring &url);
} // namespace mapupdater::net