#ifndef CEPIS_SRC_HTTP_HPP #define CEPIS_SRC_HTTP_HPP #include #include #include 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