#pragma once #include #include #include namespace dstalk { namespace net { struct HttpResponse { int status_code = 0; std::string body; std::unordered_map headers; }; /* * HTTPS 客户端统一接口 * 所有平台统一使用 Boost.Beast + OpenSSL 实现 */ class HttpClient { public: HttpClient(); ~HttpClient(); void set_timeout(int connect_sec, int request_sec); // 同步 POST JSON, 返回完整响应 HttpResponse post_json( const std::string& host, const std::string& port, const std::string& target, const std::string& json_body, const std::unordered_map& extra_headers ); // 流式 POST (SSE 逐行回调), on_line 返回 false 提前终止 using StreamCallback = std::function; HttpResponse post_stream( const std::string& host, const std::string& port, const std::string& target, const std::string& json_body, const std::unordered_map& extra_headers, StreamCallback on_line ); private: struct Impl; Impl* impl_; }; } // namespace net } // namespace dstalk