16#include <ove/net_http.h>
20#ifdef CONFIG_OVE_NET_HTTP
57 ove_http_response_free(&
raw_);
80 ove_http_response_free(&
raw_);
102 return raw_.body_len;
114 return raw_.headers_len;
121 ove_http_response_t *
raw()
151#ifdef CONFIG_OVE_ZERO_HEAP
152 int err = ove_http_client_init(&handle_, &storage_);
154 int err = ove_http_client_create(&handle_);
156 OVE_STATIC_INIT_ASSERT(err == OVE_OK);
168#ifdef CONFIG_OVE_ZERO_HEAP
169 ove_http_client_deinit(handle_);
171 ove_http_client_destroy(handle_);
178#ifdef CONFIG_OVE_ZERO_HEAP
188 other.handle_ =
nullptr;
198 if (
this != &other) {
200 ove_http_client_destroy(handle_);
201 handle_ = other.handle_;
202 other.handle_ =
nullptr;
218 const int rc = ove_http_get(handle_, url, &resp.
raw_);
219 return from_rc(rc, std::move(resp));
232 const void *body,
size_t body_len)
noexcept
236 ove_http_post(handle_, url, content_type, body, body_len, &resp.
raw_);
237 return from_rc(rc, std::move(resp));
251 const char *content_type,
const void *body,
252 size_t body_len)
noexcept
255 const int rc = ove_http_request(handle_, method, url, content_type, body, body_len,
257 return from_rc(rc, std::move(resp));
273 const char *content_type,
const void *body,
274 size_t body_len,
const ove_http_header_t *headers,
275 size_t header_count)
noexcept
278 const int rc = ove_http_request_ex(handle_, method, url, content_type, body,
279 body_len, headers, header_count, &resp.
raw_);
280 return from_rc(rc, std::move(resp));
289 return handle_ !=
nullptr;
302 ove_http_client_t handle_ =
nullptr;
303#ifdef CONFIG_OVE_ZERO_HEAP
304 ove_http_client_storage_t storage_ = {};
RAII wrapper around an oveRTOS HTTP client handle.
Definition net_http.hpp:141
Result< Response > request(ove_http_method_t method, const char *url, const char *content_type, const void *body, size_t body_len, const ove_http_header_t *headers, size_t header_count) noexcept
Performs an HTTP request with custom headers.
Definition net_http.hpp:272
~Client() noexcept
Destroys the HTTP client, releasing the underlying resource.
Definition net_http.hpp:164
Result< Response > post(const char *url, const char *content_type, const void *body, size_t body_len) noexcept
Performs an HTTP POST request.
Definition net_http.hpp:231
ove_http_client_t handle() const
Returns the raw oveRTOS HTTP client handle.
Definition net_http.hpp:296
Client & operator=(Client &&other) noexcept
Move-assignment operator – transfers ownership of the client handle.
Definition net_http.hpp:196
bool valid() const
Returns true if the underlying client handle is non-null.
Definition net_http.hpp:287
Client()
Constructs and initialises the HTTP client.
Definition net_http.hpp:149
Result< Response > request(ove_http_method_t method, const char *url, const char *content_type, const void *body, size_t body_len) noexcept
Performs a generic HTTP request.
Definition net_http.hpp:250
Result< Response > get(const char *url) noexcept
Performs an HTTP GET request.
Definition net_http.hpp:215
Client(Client &&other) noexcept
Move constructor – transfers ownership of the client handle.
Definition net_http.hpp:186
RAII wrapper around an oveRTOS HTTP response.
Definition net_http.hpp:45
int status() const
Returns the HTTP status code (e.g. 200, 404).
Definition net_http.hpp:88
const char * body() const
Returns the response body (NUL-terminated).
Definition net_http.hpp:94
~Response() noexcept
Destroys the response, freeing body and header buffers.
Definition net_http.hpp:55
ove_http_response_t raw_
Definition net_http.hpp:126
size_t headers_len() const
Returns the response headers length in bytes.
Definition net_http.hpp:112
Response()=default
Constructs an empty response.
Response & operator=(Response &&other) noexcept
Move-assignment operator – frees current buffers and takes ownership.
Definition net_http.hpp:77
const char * headers() const
Returns the raw response headers.
Definition net_http.hpp:106
size_t body_len() const
Returns the response body length in bytes.
Definition net_http.hpp:100
Response(Response &&other) noexcept
Move constructor – transfers ownership of response buffers.
Definition net_http.hpp:67
ove_http_response_t * raw()
Returns a pointer to the underlying C response struct.
Definition net_http.hpp:121
Strong ove::Error type, Result<T> alias, and std::error_code interop for the oveRTOS C++ binding.
C++ wrappers around the oveRTOS HTTP client API.
Definition net_http.hpp:23
Result< void > from_rc(int rc) noexcept
Lifts a substrate rc-code into a Result<void>.
Definition error.hpp:254
std::expected< T, Error > Result
std::expected-based result alias.
Definition error.hpp:139
Common type definitions and concepts for the C++ wrapper layer.