forgeant docs-test-0
Build LLM-powered agents in C++
Loading...
Searching...
No Matches
curl_client.hpp
Go to the documentation of this file.
1#ifndef FORGEANT_HTTP_CURL_CLIENT_HPP
2#define FORGEANT_HTTP_CURL_CLIENT_HPP
3
4#include <chrono>
6
7namespace forgeant {
8
9class CurlHttpClient : public HttpClient {
10 public:
11 struct Config {
12 std::chrono::seconds connect_timeout{30};
13 std::chrono::seconds transfer_timeout{300};
14 };
15
17 explicit CurlHttpClient(Config config);
18 ~CurlHttpClient() override;
19
22 CurlHttpClient(CurlHttpClient&& other) noexcept;
24
25 HttpResponse post(const std::string& url, const HttpHeaders& headers,
26 const std::string& body) override;
27
28 std::future<HttpResponse> async_post(const std::string& url, const HttpHeaders& headers,
29 const std::string& body) override;
30
31 HttpResponse post_stream(const std::string& url, const HttpHeaders& headers,
32 const std::string& body, StreamCallback on_chunk) override;
33
34 private:
35 struct Impl;
36 Impl* impl_;
37 Config config_;
38
39 HttpResponse perform_post(void* curl, const std::string& url, const HttpHeaders& headers,
40 const std::string& body, StreamCallback* on_chunk) const;
41};
42
43} // namespace forgeant
44
45#endif // FORGEANT_HTTP_CURL_CLIENT_HPP
Definition curl_client.hpp:9
CurlHttpClient(CurlHttpClient &&other) noexcept
HttpResponse post(const std::string &url, const HttpHeaders &headers, const std::string &body) override
std::future< HttpResponse > async_post(const std::string &url, const HttpHeaders &headers, const std::string &body) override
CurlHttpClient & operator=(CurlHttpClient &&other) noexcept
CurlHttpClient & operator=(const CurlHttpClient &)=delete
HttpResponse post_stream(const std::string &url, const HttpHeaders &headers, const std::string &body, StreamCallback on_chunk) override
CurlHttpClient(const CurlHttpClient &)=delete
CurlHttpClient(Config config)
Definition client.hpp:16
Definition agent.hpp:25
std::unordered_map< std::string, std::string > HttpHeaders
Definition client.hpp:13
std::function< bool(std::string_view)> StreamCallback
Definition client.hpp:14
Definition curl_client.hpp:11
std::chrono::seconds transfer_timeout
Definition curl_client.hpp:13
std::chrono::seconds connect_timeout
Definition curl_client.hpp:12
Definition response.hpp:9