|
|
@ -257,8 +257,12 @@ std::optional<std::string> launchpad::api_get(const std::string& endpoint, const
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
|
|
|
|
|
|
|
|
|
|
|
|
CURLcode res = curl_easy_perform(curl);
|
|
|
|
bool tries = 0;
|
|
|
|
long http_code = 0;
|
|
|
|
long http_code = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (tries < 5) {
|
|
|
|
|
|
|
|
tries++;
|
|
|
|
|
|
|
|
CURLcode res = curl_easy_perform(curl);
|
|
|
|
if (res != CURLE_OK) {
|
|
|
|
if (res != CURLE_OK) {
|
|
|
|
std::cerr << "CURL GET error: " << curl_easy_strerror(res) << std::endl;
|
|
|
|
std::cerr << "CURL GET error: " << curl_easy_strerror(res) << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -268,15 +272,18 @@ std::optional<std::string> launchpad::api_get(const std::string& endpoint, const
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
|
|
|
|
|
|
|
if (res != CURLE_OK) {
|
|
|
|
if (res != CURLE_OK) {
|
|
|
|
return std::nullopt;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (http_code >= 400) {
|
|
|
|
if (http_code >= 400) {
|
|
|
|
std::cerr << "HTTP GET request to " << url << " failed with code: " << http_code << "\nResponse: " << readBuffer << std::endl;
|
|
|
|
continue;
|
|
|
|
return std::nullopt;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return readBuffer;
|
|
|
|
return readBuffer;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::cerr << "HTTP GET request to " << url << " failed with code: " << http_code << "\nResponse: " << readBuffer << std::endl;
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::optional<std::string> launchpad::api_post(
|
|
|
|
std::optional<std::string> launchpad::api_post(
|
|
|
@ -327,8 +334,12 @@ std::optional<std::string> launchpad::api_post(
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
|
|
|
|
|
|
|
|
|
|
|
|
CURLcode res = curl_easy_perform(curl);
|
|
|
|
bool tries = 0;
|
|
|
|
long http_code = 0;
|
|
|
|
long http_code = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (tries < 5) {
|
|
|
|
|
|
|
|
tries++;
|
|
|
|
|
|
|
|
CURLcode res = curl_easy_perform(curl);
|
|
|
|
if (res != CURLE_OK) {
|
|
|
|
if (res != CURLE_OK) {
|
|
|
|
std::cerr << "CURL POST error: " << curl_easy_strerror(res) << std::endl;
|
|
|
|
std::cerr << "CURL POST error: " << curl_easy_strerror(res) << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -338,15 +349,17 @@ std::optional<std::string> launchpad::api_post(
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
|
|
|
|
|
|
|
if (res != CURLE_OK) {
|
|
|
|
if (res != CURLE_OK) {
|
|
|
|
return std::nullopt;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (http_code >= 400) {
|
|
|
|
if (http_code >= 400) {
|
|
|
|
std::cerr << "HTTP POST request to " << url << " failed with code: " << http_code << "\nResponse: " << readBuffer << std::endl;
|
|
|
|
continue;
|
|
|
|
return std::nullopt;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return readBuffer;
|
|
|
|
return readBuffer;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cerr << "HTTP POST request to " << url << " failed with code: " << http_code << "\nResponse: " << readBuffer << std::endl;
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::optional<std::string> launchpad::api_patch(const std::string& endpoint, const nlohmann::json& data) {
|
|
|
|
std::optional<std::string> launchpad::api_patch(const std::string& endpoint, const nlohmann::json& data) {
|
|
|
|