Skip to content

Class nebula::drivers::connections::HttpClient

ClassList > nebula > drivers > connections > HttpClient

A simple HTTP/1.1 client for GET and POST requests. More...

  • #include <http_client.hpp>

Public Functions

Type Name
HttpClient (const std::string & host_ip, uint16_t port)
std::string get (const std::string & endpoint, int timeout_ms=500)
Perform an HTTP GET request.
std::string post (const std::string & endpoint, const std::string & body, int timeout_ms=500)
Perform an HTTP POST request.
std::string request (const std::string & req, int timeout_ms)
Perform a raw HTTP request. Supports Content-Length responses.

Detailed Description

Note:

This client currently supports responses with Content-Length only.

Public Functions Documentation

function HttpClient

inline nebula::drivers::connections::HttpClient::HttpClient (
    const std::string & host_ip,
    uint16_t port
) 

function get

Perform an HTTP GET request.

inline std::string nebula::drivers::connections::HttpClient::get (
    const std::string & endpoint,
    int timeout_ms=500
) 

Parameters:

  • endpoint The resource path (e.g. "/api/v1/status").
  • timeout_ms Timeout associated with request. Default is 500ms.

Returns:

The response body as a string.


function post

Perform an HTTP POST request.

inline std::string nebula::drivers::connections::HttpClient::post (
    const std::string & endpoint,
    const std::string & body,
    int timeout_ms=500
) 

Parameters:

  • endpoint The resource path.
  • body The body content to send.
  • timeout_ms Timeout associated with request. Default is 500ms.

Returns:

The response body as a string.


function request

Perform a raw HTTP request. Supports Content-Length responses.

inline std::string nebula::drivers::connections::HttpClient::request (
    const std::string & req,
    int timeout_ms
) 

Parameters:

  • req A complete, well-formed HTTP request string (including headers and body).
  • timeout_ms Timeout associated with request.

Returns:

The response body as a string, decoded if chunked.



The documentation for this class was generated from the following file src/nebula_core/nebula_core_hw_interfaces/include/nebula_core_hw_interfaces/nebula_hw_interfaces_common/connections/http_client.hpp