aboutsummaryrefslogtreecommitdiffstats
path: root/httpclient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'httpclient.cpp')
-rw-r--r--httpclient.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/httpclient.cpp b/httpclient.cpp
index 83a0914..33329c6 100644
--- a/httpclient.cpp
+++ b/httpclient.cpp
@@ -72,7 +72,6 @@ int HttpClient::sendRequest(std::string &reply, const std::string &payload,
CURL *curl = curl_easy_init();
try {
if (doRequest(curl, request) != 0) {
- m_lastError += "Server not reachable ";
retVal = 1;
}
} catch(...) {
@@ -97,14 +96,14 @@ int HttpClient::sendRequest(std::string &reply, const std::string &payload,
int HttpClient::doRequest(CURL *curl, HttpRequest &request)
{
- /* send all data to this function */
+ // Set all received data to be send to our callback function
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
std::string readBuffer;
- /* we pass our 'chunk' struct to the callback function */
+ // Pass the buffer to a callback
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
- // Set the URL
+ // Set the URL / headers
curl_easy_setopt(curl, CURLOPT_URL, request.url.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, request.headers);
if (!request.payload.empty()) {
@@ -116,11 +115,11 @@ int HttpClient::doRequest(CURL *curl, HttpRequest &request)
}
curl_easy_setopt(curl, CURLOPT_TIMEOUT, SERVER_CONN_TIMEOUT);
- /* get it! */
+ // get it
CURLcode res;
res = curl_easy_perform(curl);
- /* check for errors */
+ // check for errors
if (res != CURLE_OK) {
std::cout << "HTTP transfer failed, URL: " << request.url << std::endl;
m_lastError = curl_easy_strerror(res);