// A small async HTTP/1.1 GET client over asio, with TLS support. // // Written rather than pulled in (libcurl) because we need exactly one verb, and // libcurl's threading/blocking model does not fit the single control thread we // run everything else on. Scope is deliberately narrow: GET, redirects, a hard // byte cap, and a deadline. #pragma once #include #include #include #include #include namespace ovg::http { struct Url { std::string scheme; // "http" or "https" std::string host; std::string port; // always populated (defaulted from scheme) std::string target; // path + query, starts with '/' }; bool parse_url(const std::string &text, Url *out); struct Response { int status = 0; std::string body; }; using Handler = std::function; struct Options { std::chrono::milliseconds timeout{30000}; size_t max_bytes = 32u * 1024 * 1024; int max_redirects = 3; std::string user_agent = "openvpngate/0.1"; // TLS peer verification. Only disable for a mirror you control. bool verify_tls = true; }; // Invokes `handler` exactly once, on `io`'s executor. void async_get(asio::io_context &io, const std::string &url, const Options &opts, Handler handler); } // namespace ovg::http