28 #include <fmt/format.h>
33 # include <curl/curl.h>
34 # include <curl/easy.h>
38 data->append((
char*)ptr, size * nmemb);
45 if (filesize_B <= 0.0)
52 double perc = (downloaded_B / filesize_B) * 100;
60 context->
ctc_displayname,
"File size", filesize_B/(1024 * 1024),
"MB",
"Downloaded", downloaded_B/(1024 * 1024),
"MB");
71 bool RoR::GetUrlAsString(
const std::string& url, CURLcode& curl_result,
long& response_code, std::string& response_payload)
73 std::string response_header;
76 CURL *curl = curl_easy_init();
77 curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
78 curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
80 curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA);
82 curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING,
"gzip");
83 curl_easy_setopt(curl, CURLOPT_USERAGENT, user_agent.c_str());
85 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_payload);
86 curl_easy_setopt(curl, CURLOPT_HEADERDATA, &response_header);
88 curl_result = curl_easy_perform(curl);
89 curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
91 curl_easy_cleanup(curl);
94 if (curl_result != CURLE_OK || response_code != 200)
96 Ogre::LogManager::getSingleton().stream()
97 <<
"[RoR|CURL] Failed to retrieve url '"<<url<<
"' as string;"
98 <<
" Error: '" << curl_easy_strerror(curl_result) <<
"'; HTTP status code: " << response_code;
99 response_payload = curl_easy_strerror(curl_result);
109 CURLcode curl_result = CURLE_OK;
110 long http_response = 0;
118 args->
arg2ex = http_response;
119 args->
arg3ex = curl_result;
129 args->
arg2ex = http_response;
130 args->
arg3ex = curl_result;