14 const std::string &payload)
16 curl_easy_setopt(
_curl, CURLOPT_POSTFIELDS, payload.c_str());
17 curl_easy_setopt(
_curl, CURLOPT_POSTFIELDSIZE_LARGE, payload.size());
18 curl_easy_setopt(
_curl, CURLOPT_URL, fullURL.c_str());
19 curl_easy_setopt(
_curl, CURLOPT_WRITEDATA,
static_cast<void *
>(&receivedData));
20 curl_easy_setopt(
_curl, method, 1L);
46HTTP::HTTP(std::string addr,
int timeoutInMs) : _hostAddr(std::move(addr))
50 throw std::invalid_argument(
"Can't init curl context");
53 curl_easy_setopt(
_curl, CURLOPT_VERBOSE, 0L);
54 curl_easy_setopt(
_curl, CURLOPT_FOLLOWLOCATION, 1L);
55 curl_easy_setopt(
_curl, CURLOPT_TIMEOUT_MS, timeoutInMs);
56 curl_easy_setopt(
_curl, CURLOPT_CONNECTTIMEOUT_MS, timeoutInMs);
59 curl_easy_setopt(
_curl, CURLOPT_SSLENGINE_DEFAULT, 1L);
60 curl_easy_setopt(
_curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
98 curl_easy_getinfo(
_curl, CURLINFO_SIZE_UPLOAD_T, &value);
99 stats.uploadBytes =
static_cast<size_t>(value);
100 curl_easy_getinfo(
_curl, CURLINFO_SIZE_DOWNLOAD_T, &value);
101 stats.downloadBytes =
static_cast<size_t>(value);
102 curl_easy_getinfo(
_curl, CURLINFO_HEADER_SIZE, &value);
103 stats.headerBytes =
static_cast<size_t>(value);
104 curl_easy_getinfo(
_curl, CURLINFO_REQUEST_SIZE, &value);
105 stats.requestBytes =
static_cast<size_t>(value);
106 curl_easy_getinfo(
_curl, CURLINFO_SPEED_UPLOAD_T, &value);
107 stats.uploadSpeed = value;
108 curl_easy_getinfo(
_curl, CURLINFO_SPEED_DOWNLOAD_T, &value);
109 stats.downloadSpeed = value;
110 curl_easy_getinfo(
_curl, CURLINFO_CONNECT_TIME_T, &value);
111 stats.connectionTime = value;
112 curl_easy_getinfo(
_curl, CURLINFO_NAMELOOKUP_TIME_T, &value);
113 stats.nameLookupTime = value;
114 curl_easy_getinfo(
_curl, CURLINFO_PRETRANSFER_TIME_T, &value);
115 stats.preTransferTime = value;
116 curl_easy_getinfo(
_curl, CURLINFO_REDIRECT_TIME_T, &value);
117 stats.redirectTime = value;
118 curl_easy_getinfo(
_curl, CURLINFO_STARTTRANSFER_TIME_T, &value);
119 stats.startTransferTime = value;
120 curl_easy_getinfo(
_curl, CURLINFO_TOTAL_TIME_T, &value);
121 stats.totalTime = value;