Files

36 lines
779 B
C++
Raw Permalink Normal View History

#pragma once
#include <windows.h>
#include <functional>
#include <string>
namespace updater {
struct HttpResult {
long status = 0;
std::string body;
};
class Http {
public:
using ProgressFunc = std::function<bool(unsigned long long received,
unsigned long long total)>;
static bool Get(const std::wstring& url, HttpResult& out, std::wstring& err);
static bool Download(const std::wstring& url,
const std::wstring& savePath,
ProgressFunc progress,
std::wstring& err);
static void SetTimeoutSec(int sec) { timeoutSec_ = sec; }
static int TimeoutMs() { return timeoutSec_ * 1000; }
private:
static int timeoutSec_;
};
}