Moving to a poll method for workers, and daggyd-preserved capacities
This commit is contained in:
@@ -234,7 +234,7 @@ namespace daggy {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlWriter);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 2);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);
|
||||
|
||||
if (trace) {
|
||||
curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, http_trace);
|
||||
@@ -254,8 +254,9 @@ namespace daggy {
|
||||
|
||||
if (res != CURLE_OK) {
|
||||
curl_easy_cleanup(curl);
|
||||
throw std::runtime_error(std::string{"CURL Failed: "} +
|
||||
curl_easy_strerror(res));
|
||||
response.code = HTTPCode::Server_Error;
|
||||
response.body = std::string{"CURL Failed: "} + curl_easy_strerror(res);
|
||||
return response;
|
||||
}
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
@@ -275,7 +276,18 @@ namespace daggy {
|
||||
auto response = HTTP_REQUEST(url, payload, method);
|
||||
|
||||
rj::Document doc;
|
||||
checkRJParse(doc.Parse(response.body.c_str()));
|
||||
if (response.code == HTTPCode::Server_Error) {
|
||||
doc.SetObject();
|
||||
auto &alloc = doc.GetAllocator();
|
||||
doc.AddMember("error",
|
||||
rj::Value().SetString(response.body.c_str(),
|
||||
response.body.size(), alloc),
|
||||
alloc);
|
||||
}
|
||||
else {
|
||||
checkRJParse(doc.Parse(response.body.c_str()));
|
||||
}
|
||||
|
||||
return std::make_pair(response.code, std::move(doc));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user