#include <Http.hpp>
Public Member Functions | |
| HTTP (std::string addr, int timeoutInMs=HTTP_TIMEOUT_MS) | |
| HTTP (const HTTP &)=delete | |
| Copy constructor. | |
| HTTP (HTTP &&)=delete | |
| Move constructor. | |
| HTTP & | operator= (HTTP)=delete |
| Copy assignment operator. | |
| HTTP & | operator= (HTTP &&)=delete |
| Move assignment operator. | |
| template<typename T > | |
| bool | setOption (CURLoption option, T value) |
| const std::string & | getHostAddress () const |
| CURLcode | sendGETRequest (const std::string &index, std::string &receivedData, HttpStatus::Code &statusCode) |
| CURLcode | sendHEADRequest (const std::string &index, std::string &receivedData, HttpStatus::Code &statusCode) |
| CURLcode | sendPOSTRequest (const std::string &index, const std::string &payload, std::string &receivedData, HttpStatus::Code &statusCode) |
| CURLcode | sendPUTRequest (const std::string &index, const std::string &payload, std::string &receivedData, HttpStatus::Code &statusCode) |
| HTTPStats | getStats () |
| ~HTTP () | |
Private Member Functions | |
| void | setCommonFields (const std::string &fullURL, CURLoption method) |
| void | setCommonFields (const std::string &fullURL, CURLoption method, const std::string &payload) |
| CURLcode | performRequest (HttpStatus::Code &statusCode, std::string &receivedData) |
Static Private Member Functions | |
| static size_t | writeDataCallback (const char *contents, size_t size, size_t nmemb, std::string *userp) |
Private Attributes | |
| CURL * | _curl = curl_easy_init() |
| CURL handler. | |
| std::unique_ptr< curlMemory > | _data = std::make_unique<curlMemory>() |
| Memory structure for CURL. | |
| std::string | _hostAddr |
| Full path of server. | |
|
explicit |
Constructs a new HTTP object
| [in] | addr | The full path to the server |
| [in] | timeoutInMs | The connection timeout in milliseconds |
Definition at line 52 of file Http.cpp.

|
delete |
Copy constructor.
|
delete |
Move constructor.
| HTTP::~HTTP | ( | ) |
|
inlinenodiscard |
| HTTPStats HTTP::getStats | ( | ) |
Gets the statistics of the HTTP object
Definition at line 99 of file Http.cpp.
|
private |
Performs the request
| [out] | statusCode | The HTTP status code |
| [out] | receivedData | The received reply from the server |
Definition at line 24 of file Http.cpp.

| CURLcode HTTP::sendGETRequest | ( | const std::string & | index, |
| std::string & | receivedData, | ||
| HttpStatus::Code & | statusCode ) |
Sends a GET request
| [in] | index | The value to append to the server address |
| [out] | receivedData | The received reply from the server |
| [out] | statusCode | The HTTP status code (set if CURLE_OK, otherwise unchanged) |
Definition at line 69 of file Http.cpp.

| CURLcode HTTP::sendHEADRequest | ( | const std::string & | index, |
| std::string & | receivedData, | ||
| HttpStatus::Code & | statusCode ) |
Sends a HEAD request
| [in] | index | The value to append to the server address |
| [out] | receivedData | The received reply from the server |
| [out] | statusCode | The HTTP status code (set if CURLE_OK, otherwise unchanged) |
Definition at line 76 of file Http.cpp.

| CURLcode HTTP::sendPOSTRequest | ( | const std::string & | index, |
| const std::string & | payload, | ||
| std::string & | receivedData, | ||
| HttpStatus::Code & | statusCode ) |
Sends a POST request
| [in] | index | The value to append to the server address |
| [in] | payload | The payload to send to the server |
| [out] | receivedData | The received reply from the server |
| [out] | statusCode | The HTTP status code (set if CURLE_OK, otherwise unchanged) |
Definition at line 83 of file Http.cpp.

| CURLcode HTTP::sendPUTRequest | ( | const std::string & | index, |
| const std::string & | payload, | ||
| std::string & | receivedData, | ||
| HttpStatus::Code & | statusCode ) |
Sends a PUT request
| [in] | index | The value to append to the server address |
| [in] | payload | The payload to send to the server |
| [out] | receivedData | The received reply from the server |
| [out] | statusCode | The HTTP status code (set if CURLE_OK, otherwise unchanged) |
Definition at line 91 of file Http.cpp.

|
private |
Sets common fields for HTTP requests
| [in] | fullURL | The full URL of the request |
| [in] | method | The HTTP method to use |
Definition at line 6 of file Http.cpp.

|
private |
Sets common fields for HTTP requests with payload
| [in] | fullURL | The full URL of the request |
| [in] | method | The HTTP method to use |
| [in] | payload | The payload to send to the server |
Definition at line 14 of file Http.cpp.
|
inline |
|
staticprivate |
Callback function for writing received data
| [in] | contents | The received data |
| [in] | size | The size of each element |
| [in] | nmemb | The number of elements |
| [in] | userp | User pointer to a string |
Definition at line 39 of file Http.cpp.

|
private |