#pragma once // Thin bounded HTTP helper for the MCP and A2A clients: absolute http(s) // URLs only, response body capped, non-2xx and transport failures mapped to // AdkError ("upstream"). Runs over any clients::Client (MockTransport in // tests). #include #include #include #include "clients/body/json.h" #include "clients/client.h" namespace molo::google::adk { struct RemoteReply { int status = 0; clients::HeaderMap headers; std::string body; }; class RemoteHttp { public: // headers are sent on every request (e.g. Authorization). They are never // echoed into errors. explicit RemoteHttp(std::shared_ptr http, std::map headers = {}); RemoteReply post_json(const std::string& url, const clients::body::Json& body, const std::map& extra = {}); RemoteReply get(const std::string& url, const std::map& extra = {}); // True for an absolute http:// or https:// URL without whitespace. static bool valid_url(const std::string& url); private: RemoteReply finish(const std::string& url, clients::ClientRequest request); std::shared_ptr http_; std::map headers_; }; } // namespace molo::google::adk