NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
http_client.h
Go to the documentation of this file.
1
14#pragma once
15
16#include <neograph/api.h>
17
18#include <asio/awaitable.hpp>
19#include <asio/any_io_executor.hpp>
20
21#include <chrono>
22#include <functional>
23#include <string>
24#include <string_view>
25#include <utility>
26#include <vector>
27
28namespace neograph::async {
29
30struct NEOGRAPH_API HttpResponse {
31 int status = 0;
32 std::string body;
33
38 std::string retry_after;
39
44 std::string location;
45
56 std::vector<std::pair<std::string, std::string>> headers;
57
61 std::string_view get_header(std::string_view name) const noexcept;
62};
63
71 std::chrono::milliseconds timeout{0};
72
79};
80
99NEOGRAPH_API asio::awaitable<HttpResponse> async_post(
100 asio::any_io_executor ex,
101 std::string_view host,
102 std::string_view port,
103 std::string_view path,
104 std::string_view body,
105 std::vector<std::pair<std::string, std::string>> headers = {},
106 bool tls = false,
107 RequestOptions opts = {});
108
113NEOGRAPH_API asio::awaitable<HttpResponse> async_get(
114 asio::any_io_executor ex,
115 std::string_view host,
116 std::string_view port,
117 std::string_view path,
118 std::vector<std::pair<std::string, std::string>> headers = {},
119 bool tls = false,
120 RequestOptions opts = {});
121
126 int status = 0;
127};
128
147NEOGRAPH_API asio::awaitable<HttpStreamResponse> async_post_stream(
148 asio::any_io_executor ex,
149 std::string_view host,
150 std::string_view port,
151 std::string_view path,
152 std::string_view body,
153 std::vector<std::pair<std::string, std::string>> headers,
154 bool tls,
155 std::function<void(std::string_view chunk)> on_chunk,
156 RequestOptions opts = {});
157
158} // namespace neograph::async
NEOGRAPH_API export/import macro for shared-library builds.
NEOGRAPH_API asio::awaitable< HttpStreamResponse > async_post_stream(asio::any_io_executor ex, std::string_view host, std::string_view port, std::string_view path, std::string_view body, std::vector< std::pair< std::string, std::string > > headers, bool tls, std::function< void(std::string_view chunk)> on_chunk, RequestOptions opts={})
Async HTTP(S) POST where the server emits a Transfer-Encoding: chunked response body.
NEOGRAPH_API asio::awaitable< HttpResponse > async_post(asio::any_io_executor ex, std::string_view host, std::string_view port, std::string_view path, std::string_view body, std::vector< std::pair< std::string, std::string > > headers={}, bool tls=false, RequestOptions opts={})
Async HTTP(S) POST.
NEOGRAPH_API asio::awaitable< HttpResponse > async_get(asio::any_io_executor ex, std::string_view host, std::string_view port, std::string_view path, std::vector< std::pair< std::string, std::string > > headers={}, bool tls=false, RequestOptions opts={})
Async HTTP(S) GET.
Metadata returned by async_post_stream after the body has been fully delivered via the callback.
std::chrono::milliseconds timeout
Per-hop deadline covering connect + handshake + write + read of one HTTP exchange.
Definition http_client.h:71
int max_redirects
Max 3xx hops to follow automatically.
Definition http_client.h:78