-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhttpclient.hpp
49 lines (39 loc) · 1.66 KB
/
httpclient.hpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <utils/object.hpp>
#include <curl/curl.h>
#include <filesystem>
#include <map>
#include <memory>
class HttpClient : noncopyable
{
public:
using Headers = std::map<std::string, std::string>;
HttpClient();
~HttpClient();
auto get(const std::string &url, const Headers &headers = {}) -> std::string;
auto post(const std::string &url, const std::string &data, const Headers &headers = {})
-> std::string;
auto put(const std::string &url, const std::string &data, const Headers &headers = {})
-> std::string;
auto del(const std::string &url, const Headers &headers = {}) -> std::string;
auto options(const std::string &url, const Headers &headers = {}) -> std::string;
auto patch(const std::string &url, const std::string &data, const Headers &headers = {})
-> std::string;
auto sendCustomRequest(const std::string &url,
const std::string &method,
const std::string &data,
const Headers &headers = {}) -> std::string;
auto download(const std::string &url,
const std::filesystem::path &path,
const Headers &headers = {}) -> bool;
auto upload_put(const std::string &url,
const std::filesystem::path &path,
const Headers &headers = {}) -> bool;
auto upload_post(const std::string &url,
const std::filesystem::path &path,
const Headers &headers = {}) -> bool;
[[nodiscard]] auto error() const -> std::string;
private:
class HttpClientPrivate;
std::unique_ptr<HttpClientPrivate> d_ptr;
};