#pragma once #include #include #include #include #include #include #include #include #include // ADR-0182 section 15: a bounded, blocking HTTPS/1.1 client for the admin API's two outbound // services (Gitea and Argo CD). One request per connection (Connection: close); the system // trust store and host name check unless `verify` is false. Credentials travel only in the // request headers and are never logged. namespace evo::server::admin { struct HttpsRequest { std::string host; std::uint16_t port{443}; std::string method{"GET"}; std::string target{"/"}; // Path and query, already percent-encoded. std::vector> headers; std::string body; bool verify{true}; std::chrono::milliseconds timeout{10'000}; std::size_t limit{std::size_t{4} << 20U}; // Largest body accepted. }; struct HttpsResponse { int status{}; std::string body; }; // The transport the admin API uses; tests substitute a fake. using HttpsTransport = std::function(const HttpsRequest&)>; // Sends `request` over TLS: the answer, or nullopt on any connection, TLS, timeout, size or // framing failure. [[nodiscard]] std::optional https_request(const HttpsRequest& request); // An HTTP/1.1 response read to the end of the connection: the status and the body (by // Content-Length, chunked, or to the end), or nullopt when malformed or over `limit`. [[nodiscard]] std::optional parse_http_response(std::string_view raw, std::size_t limit); // "https://host[:port][/...]" split into host, port and the path prefix (no trailing slash). struct HttpsBase { std::string host; std::uint16_t port{443}; std::string prefix; }; [[nodiscard]] std::optional parse_https_base(std::string_view url); } // namespace evo::server::admin