Remove HTTP functionality
It wasn't used so it can be removed.
This commit is contained in:
@ -1294,51 +1294,4 @@ size_t header_callback(char* ptr, size_t size, size_t nmemb, void* userdata)
|
||||
}
|
||||
}
|
||||
|
||||
namespace http
|
||||
{
|
||||
|
||||
Result get(const std::string& url, const std::string& user, const std::string& password)
|
||||
{
|
||||
Result res;
|
||||
char errbuf[CURL_ERROR_SIZE + 1] = "";
|
||||
CURL* curl = curl_easy_init();
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10); // For connection phase
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10); // For data transfer phase
|
||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &res.raw_body);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &res.headers);
|
||||
|
||||
if (!user.empty() && !password.empty())
|
||||
{
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, (user + ":" + password).c_str());
|
||||
}
|
||||
|
||||
long code = 0; // needs to be a long
|
||||
|
||||
if (curl_easy_perform(curl) == CURLE_OK)
|
||||
{
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
|
||||
res.code = code;
|
||||
}
|
||||
else
|
||||
{
|
||||
res.code = -1;
|
||||
res.raw_body = errbuf;
|
||||
}
|
||||
|
||||
// Even the errors are valid JSON so this should be OK
|
||||
json_error_t err;
|
||||
res.body.reset(json_loads(res.raw_body.c_str(), 0, &err));
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
return std::move(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user