Fledge
An open source edge computing platform for industrial users
LibcurlHttps Class Reference
Inheritance diagram for LibcurlHttps:
Collaboration diagram for LibcurlHttps:

Public Member Functions

 LibcurlHttps (const std::string &host_port, unsigned int connect_timeout=0, unsigned int request_timeout=0, unsigned int retry_sleep_Time=1, unsigned int max_retry=4)
 Constructor: pass host:port, connect & request timeouts, retry_sleep_Time, max_retry.
 
 ~LibcurlHttps ()
 Destructor.
 
void setProxy (const std::string &proxy)
 Set the proxy host and port. More...
 
int sendRequest (const std::string &method=std::string(HTTP_SENDER_DEFAULT_METHOD), const std::string &path=std::string(HTTP_SENDER_DEFAULT_PATH), const std::vector< std::pair< std::string, std::string >> &headers={}, const std::string &payload=std::string())
 HTTP(S) request: pass method and path, HTTP headers and POST/PUT payload. More...
 
void setAuthMethod (std::string &authMethod)
 
void setAuthBasicCredentials (std::string &authBasicCredentials)
 
void setOCSNamespace (std::string &OCSNamespace)
 
void setOCSTenantId (std::string &OCSTenantId)
 
void setOCSClientId (std::string &OCSClientId)
 
void setOCSClientSecret (std::string &OCSClientSecret)
 
void setOCSToken (std::string &OCSToken)
 
std::string getHostPort ()
 
std::string getHTTPResponse ()
 
- Public Member Functions inherited from HttpSender
 HttpSender ()
 Constructor: More...
 
virtual ~HttpSender ()
 Destructor.
 

Additional Inherited Members

- Static Public Member Functions inherited from HttpSender
static std::string getOMFTracePath ()
 Constructs the file path for the OMF log. More...
 
static bool createDebugTraceDirectory ()
 Creates the '/logs/debug-trace' subdirectory in the Fledge data directory. More...
 

Member Function Documentation

◆ sendRequest()

int LibcurlHttps::sendRequest ( const std::string &  method = std::string(HTTP_SENDER_DEFAULT_METHOD),
const std::string &  path = std::string(HTTP_SENDER_DEFAULT_PATH),
const std::vector< std::pair< std::string, std::string >> &  headers = {},
const std::string &  payload = std::string() 
)
virtual

HTTP(S) request: pass method and path, HTTP headers and POST/PUT payload.

Send data, it retries the operation m_max_retry times waiting m_retry_sleep_time*2 at each attempt.

Parameters
methodThe HTTP method (GET, POST, ...)
pathThe URL path
headersThe optional headers to send
payloadThe optional data payload (for POST, PUT)
Returns
The HTTP code for the cases : 1xx Informational / 2xx Success / 3xx Redirection
Exceptions
BadRequestfor HTTP 400 error std::exception as generic exception for all the cases >= 401 Client errors / 5xx Server errors

Implements HttpSender.

◆ setProxy()

void LibcurlHttps::setProxy ( const std::string &  proxy)
virtual

Set the proxy host and port.

Add a proxy server.

Parameters
proxyThe host and port of the proxy

Implements HttpSender.


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