46 bool is_open()
const override {
return open_.load(); }
53 std::atomic<bool> open_{
false};
81 static std::unique_ptr<HttpStream>
get(std::string_view url,
82 int timeout_seconds = 30);
85 static std::unique_ptr<HttpStream>
post(std::string_view url,
86 std::string_view body,
87 std::string_view content_type =
"application/json",
88 int timeout_seconds = 30);
100 const std::map<std::string, std::string>&
headers()
const {
return response_.headers; }
110 std::size_t read_pos_ = 0;
111 bool closed_ =
false;
StreamResult write(const std::uint8_t *buffer, std::size_t size) override
Write up to size bytes from buffer.
const std::map< std::string, std::string > & headers() const
Parsed response headers (lowercased keys are not normalized — they come through verbatim from cpp-htt...
Definition network_stream.hpp:100
void close() override
Close the stream. Idempotent.
static std::unique_ptr< HttpStream > get(std::string_view url, int timeout_seconds=30)
Convenience factory for GET requests.
int status_code() const
HTTP status code of the response, or 0 if the request failed.
Definition network_stream.hpp:96
static std::unique_ptr< HttpStream > post(std::string_view url, std::string_view body, std::string_view content_type="application/json", int timeout_seconds=30)
Convenience factory for POST requests.
bool eof() const
True when the HTTP response body was fully consumed by read().
bool is_open() const override
True while the stream is usable for read/write.
const std::string & transport_error() const
Non-empty when the request failed locally (network error, DNS, etc.).
Definition network_stream.hpp:103
HttpStream(const Request &request)
bool fetch(const Request &request)
Issue a new request, replacing any prior state.
StreamResult read(std::uint8_t *buffer, std::size_t size) override
Read up to size bytes into buffer.
Stream(const Stream &)=delete
StreamResult read(std::uint8_t *buffer, std::size_t size) override
Read up to size bytes into buffer.
StreamResult write(const std::uint8_t *buffer, std::size_t size) override
Write up to size bytes from buffer.
TcpStream(TcpStream &&) noexcept
void close() override
Close the stream. Idempotent.
TcpStream(Socket &&connected)
Socket & socket()
Access the underlying socket (advanced use: set options, inspect fd).
Definition network_stream.hpp:49
void shutdown()
Mark the stream closed and interrupt blocking I/O without releasing the socket handle.
bool is_open() const override
True while the stream is usable for read/write.
Definition network_stream.hpp:46
bool connect(std::string_view host, std::uint16_t port)
Bounded event contracts shared by host ingress and graph-authored nodes.
Definition anticipation_eligibility.hpp:9
Definition generated_event_source.hpp:33
Definition network_stream.hpp:66
std::string url
Definition network_stream.hpp:67
std::string body
Only used for POST.
Definition network_stream.hpp:69
int timeout_seconds
Definition network_stream.hpp:71
std::string method
"GET" or "POST".
Definition network_stream.hpp:68
std::string content_type
Definition network_stream.hpp:70
Result of a Stream read/write.
Definition stream.hpp:45