Skip to content
API Documentation
BastionGuard™
HttpClient.hpp
Go to the documentation of this file.
1/*
2 * BastionGuard™
3 * Copyright (C) 2025–2026 Calogero Scarnà
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 * BastionGuard™ is a trademark of Calogero Scarnà.
18 * The BastionGuard™ name and branding are not licensed under the GPL.
19 */
20
21#pragma once
22
23#include <string>
24#include <map>
25
27 int status = 0;
28 std::string body;
29 std::string error;
30};
31
33public:
34
35 static HttpResponse get(
36 const std::string& url,
37 const std::map<std::string, std::string>& headers = {},
38 long timeoutSeconds = 20);
39
40
41 static HttpResponse post(
42 const std::string& url,
43 const std::string& body,
44 const std::map<std::string, std::string>& headers = {},
45 long timeoutSeconds = 20);
46
47
48 static std::string urlEncode(const std::string& value);
49
50private:
51 static void ensureCurlGlobalInit();
52
53 static HttpResponse perform(
54 const std::string& url,
55 const char* method,
56 const std::string& requestBody,
57 const std::map<std::string, std::string>& headers,
58 long timeoutSeconds);
59};
static HttpResponse get(const std::string &url, const std::map< std::string, std::string > &headers={}, long timeoutSeconds=20)
static void ensureCurlGlobalInit()
static std::string urlEncode(const std::string &value)
static HttpResponse post(const std::string &url, const std::string &body, const std::map< std::string, std::string > &headers={}, long timeoutSeconds=20)
static HttpResponse perform(const std::string &url, const char *method, const std::string &requestBody, const std::map< std::string, std::string > &headers, long timeoutSeconds)
std::string error
std::string body