oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ove::http::Client Class Reference

RAII wrapper around an oveRTOS HTTP client handle. More...

#include <net_http.hpp>

Public Member Functions

 Client ()
 Constructs and initialises the HTTP client.
 
 ~Client () noexcept
 Destroys the HTTP client, releasing the underlying resource.
 
 Client (const Client &)=delete
 
Clientoperator= (const Client &)=delete
 
 Client (Client &&other) noexcept
 Move constructor – transfers ownership of the client handle.
 
Clientoperator= (Client &&other) noexcept
 Move-assignment operator – transfers ownership of the client handle.
 
Result< Responseget (const char *url) noexcept
 Performs an HTTP GET request.
 
Result< Responsepost (const char *url, const char *content_type, const void *body, size_t body_len) noexcept
 Performs an HTTP POST request.
 
Result< Responserequest (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.
 
Result< Responserequest (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.
 
bool valid () const
 Returns true if the underlying client handle is non-null.
 
ove_http_client_t handle () const
 Returns the raw oveRTOS HTTP client handle.
 

Detailed Description

RAII wrapper around an oveRTOS HTTP client handle.

Constructs the underlying HTTP client on creation and destroys it on destruction. With CONFIG_OVE_ZERO_HEAP the client storage is held inline in the wrapper; move operations are therefore disabled in that configuration because the kernel may hold a pointer to the internal buffer.

Note
Non-copyable. Move-only when heap allocation is enabled.

Constructor & Destructor Documentation

◆ Client() [1/2]

ove::http::Client::Client ( )
inline

Constructs and initialises the HTTP client.

Calls ove_http_client_init (zero-heap) or ove_http_client_create (heap). Asserts at startup if initialisation fails.

◆ ~Client()

ove::http::Client::~Client ( )
inlinenoexcept

Destroys the HTTP client, releasing the underlying resource.

If the handle is null (e.g., after a move), the destructor is a no-op.

◆ Client() [2/2]

ove::http::Client::Client ( Client &&  other)
inlinenoexcept

Move constructor – transfers ownership of the client handle.

Parameters
otherThe source; its handle is set to null after the move.

Member Function Documentation

◆ operator=()

Client & ove::http::Client::operator= ( Client &&  other)
inlinenoexcept

Move-assignment operator – transfers ownership of the client handle.

Parameters
otherThe source; its handle is set to null after the move.
Returns
Reference to this object.

◆ get()

Result< Response > ove::http::Client::get ( const char *  url)
inlinenoexcept

Performs an HTTP GET request.

Parameters
[in]urlFull URL (e.g. "http://example.com/path").
Returns
On success, the populated Response (owns the body and header buffers). On failure, an unexpected Error.

◆ post()

Result< Response > ove::http::Client::post ( const char *  url,
const char *  content_type,
const void *  body,
size_t  body_len 
)
inlinenoexcept

Performs an HTTP POST request.

Parameters
[in]urlFull URL.
[in]content_typeContent-Type header value.
[in]bodyRequest body data.
[in]body_lenRequest body length in bytes.
Returns
On success, the populated Response. On failure, an unexpected Error.

◆ request() [1/2]

Result< Response > ove::http::Client::request ( ove_http_method_t  method,
const char *  url,
const char *  content_type,
const void *  body,
size_t  body_len 
)
inlinenoexcept

Performs a generic HTTP request.

Parameters
[in]methodHTTP method (GET, POST, …).
[in]urlFull URL.
[in]content_typeContent-Type (may be NULL for GET).
[in]bodyRequest body (may be NULL).
[in]body_lenRequest body length.
Returns
On success, the populated Response. On failure, an unexpected Error.

◆ request() [2/2]

Result< Response > ove::http::Client::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 
)
inlinenoexcept

Performs an HTTP request with custom headers.

Parameters
[in]methodHTTP method.
[in]urlFull URL.
[in]content_typeContent-Type (may be NULL).
[in]bodyRequest body (may be NULL).
[in]body_lenRequest body length.
[in]headersArray of extra request headers.
[in]header_countNumber of headers.
Returns
On success, the populated Response. On failure, an unexpected Error.

◆ valid()

bool ove::http::Client::valid ( ) const
inline

Returns true if the underlying client handle is non-null.

Returns
true when the client was successfully initialised.

◆ handle()

ove_http_client_t ove::http::Client::handle ( ) const
inline

Returns the raw oveRTOS HTTP client handle.

Returns
The opaque ove_http_client_t handle.

The documentation for this class was generated from the following file: