Mads
Multi-Agent Distributed System
Loading...
Searching...
No Matches
https_client.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <map>
5
6namespace Mads {
7
19public:
24 struct Response {
25 int status_code = 0;
26 std::string status_message;
27 std::string body;
28 };
29
32
33 // Non-copyable
34 HttpsClient(const HttpsClient&) = delete;
36
41 void set_hostname(const std::string& hostname);
42
47 void set_path(const std::string& path);
48
53 void set_user_agent(const std::string& user_agent);
54
60 void add_query_pair(const std::string& k, const std::string &v);
61
62 std::string query_string();
63
70
71private:
72 std::string _hostname;
73 std::string _user_agent;
74 std::string _path;
75 std::map<std::string, std::string> _query;
76
77#ifdef _WIN32
78 Response _get_windows();
79#elif __ANDROID__
80 Response _get_unsupported();
81#elif __APPLE__
82 Response _get_macos();
83#else
84 Response _get_linux();
85#endif
86};
87
88} // namespace Mads
Portable HTTPS GET client with zero external dependencies.
void add_query_pair(const std::string &k, const std::string &v)
Add a query pair.
void set_hostname(const std::string &hostname)
Set the remote hostname (without https:// prefix)
HttpsClient(const HttpsClient &)=delete
HttpsClient & operator=(const HttpsClient &)=delete
std::string query_string()
void set_user_agent(const std::string &user_agent)
Set the User-Agent header.
Response get()
Perform HTTPS GET request to configured endpoint.
void set_path(const std::string &path)
Set the API path on the remote server.
Definition agent.hpp:67
Result of an HTTPS GET request.
std::string body
Response body as string.
int status_code
HTTP status code (e.g., 200, 404)
std::string status_message
HTTP status message (e.g., "OK")