summaryrefslogtreecommitdiffstats
path: root/src/http.hpp
diff options
context:
space:
mode:
authorMurilo Ijanc <[email protected]>2026-07-26 12:28:10 -0300
committerMurilo Ijanc <[email protected]>2026-07-26 12:28:10 -0300
commitb71faa6e95a0736f1ff171e006b171467b65db90 (patch)
tree7580c3ab515e8f50726dc68dbc240995ff4a1a4c /src/http.hpp
downloadcpp-b71faa6e95a0736f1ff171e006b171467b65db90.tar.gz
Initial importv0.1.0
Diffstat (limited to 'src/http.hpp')
-rw-r--r--src/http.hpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/http.hpp b/src/http.hpp
new file mode 100644
index 0000000..601a2d5
--- /dev/null
+++ b/src/http.hpp
@@ -0,0 +1,39 @@
+#ifndef CEPIS_SRC_HTTP_HPP
+#define CEPIS_SRC_HTTP_HPP
+
+#include <chrono>
+#include <string>
+#include <string_view>
+
+namespace cepis::detail {
+
+/// What one attempt asked for.
+struct HttpRequest {
+ std::string url;
+ std::string user_agent;
+ std::chrono::milliseconds timeout{0};
+};
+
+/// What one attempt got back.
+///
+/// `completed` separates "the server answered, here is its status" from "the
+/// request never got there" — the two need different errors, and only the
+/// second one has a `curl_error` worth showing.
+struct HttpResult {
+ bool completed = false;
+ int status = 0;
+ std::string body;
+ std::string retry_after;
+ std::string curl_error;
+};
+
+/// Performs one GET. Never throws; failures arrive in `HttpResult`.
+HttpResult perform_get(const HttpRequest& request);
+
+/// Percent-encodes `value` for use in a query-string value, RFC 3986
+/// unreserved set. A comma becomes `%2C`.
+std::string url_escape(std::string_view value);
+
+} // namespace cepis::detail
+
+#endif // CEPIS_SRC_HTTP_HPP