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

Public Member Functions

 SimpleHttps (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.
 
 ~SimpleHttps ()
 Destructor.
 
void setProxy (const std::string &proxy)
 Set the host and port of the proxy server. 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 getHTTPResponse ()
 
std::string getHostPort ()
 
- 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 SimpleHttps::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 SimpleHttps::setProxy ( const std::string &  proxy)
virtual

Set the host and port of the proxy server.

Set a proxy server.

Parameters
proxyThe name and port of the proxy server

Implements HttpSender.


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