ADD: changed the way of retreiving the result from the curl request
This commit is contained in:
@@ -198,11 +198,9 @@ namespace kubecontrol
|
||||
curlpp::Cleanup cleaner;
|
||||
curlpp::Easy request;
|
||||
|
||||
WriterMemoryClass mWriterChunk;
|
||||
curlpp::types::WriteFunctionFunctor functor = std::bind(&WriterMemoryClass::WriteMemoryCallback, &mWriterChunk, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(functor);
|
||||
request.setOpt(test);
|
||||
|
||||
std::stringstream result;
|
||||
request.setOpt(cURLpp::Options::WriteStream(&result));
|
||||
|
||||
request.setOpt(new curlpp::options::HttpHeader(headers));
|
||||
|
||||
request.setOpt(new curlpp::options::Url(curlURL));
|
||||
@@ -226,7 +224,7 @@ namespace kubecontrol
|
||||
request.perform();
|
||||
|
||||
request.reset();
|
||||
std::string response = mWriterChunk.getResponse();
|
||||
std::string response = result.str();
|
||||
InfoPod.update(response);
|
||||
while (InfoPod.Status != "Running" && InfoPod.Status != "Succeeded") {
|
||||
|
||||
@@ -252,10 +250,8 @@ namespace kubecontrol
|
||||
curlpp::Cleanup cleaner;
|
||||
curlpp::Easy request;
|
||||
|
||||
WriterMemoryClass mWriterChunk;
|
||||
curlpp::types::WriteFunctionFunctor functor = std::bind(&WriterMemoryClass::WriteMemoryCallback, &mWriterChunk, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
curlpp::options::WriteFunction *writefunction = new curlpp::options::WriteFunction(functor);
|
||||
request.setOpt(writefunction);
|
||||
std::stringstream result;
|
||||
request.setOpt(cURLpp::Options::WriteStream(&result));
|
||||
|
||||
request.setOpt(new curlpp::options::HttpHeader(headers));
|
||||
request.setOpt(new curlpp::options::Url(curlURL));
|
||||
@@ -269,7 +265,7 @@ namespace kubecontrol
|
||||
|
||||
|
||||
request.perform();
|
||||
auto response = mWriterChunk.getResponse();
|
||||
auto response = result.str();
|
||||
|
||||
LOG_S(INFO)<<InfoPod.getRelatedPods().size();
|
||||
if (InfoPod.getRelatedPods().size() > 0)
|
||||
@@ -297,10 +293,8 @@ namespace kubecontrol
|
||||
curlpp::Cleanup cleaner;
|
||||
curlpp::Easy request;
|
||||
|
||||
WriterMemoryClass mWriterChunk;
|
||||
curlpp::types::WriteFunctionFunctor functor = std::bind(&WriterMemoryClass::WriteMemoryCallback, &mWriterChunk, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
curlpp::options::WriteFunction *writefunction = new curlpp::options::WriteFunction(functor);
|
||||
request.setOpt(writefunction);
|
||||
std::stringstream result;
|
||||
request.setOpt(cURLpp::Options::WriteStream(&result));
|
||||
|
||||
request.setOpt(new curlpp::options::HttpHeader(headers));
|
||||
request.setOpt(new curlpp::options::Url(curlURL));
|
||||
@@ -314,7 +308,7 @@ namespace kubecontrol
|
||||
|
||||
|
||||
request.perform();
|
||||
auto response = mWriterChunk.getResponse();
|
||||
auto response = result.str();
|
||||
|
||||
|
||||
return response;
|
||||
@@ -334,12 +328,9 @@ namespace kubecontrol
|
||||
curlpp::Cleanup cleaner;
|
||||
curlpp::Easy request;
|
||||
|
||||
WriterMemoryClass mWriterChunk;
|
||||
std::stringstream result;
|
||||
request.setOpt(cURLpp::Options::WriteStream(&result));
|
||||
|
||||
curlpp::types::WriteFunctionFunctor functor = std::bind(&WriterMemoryClass::WriteMemoryCallback, &mWriterChunk, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
|
||||
curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(functor);
|
||||
request.setOpt(test);
|
||||
|
||||
request.setOpt(new curlpp::options::HttpHeader(headers));
|
||||
|
||||
@@ -349,7 +340,7 @@ namespace kubecontrol
|
||||
|
||||
|
||||
request.perform();
|
||||
return mWriterChunk.getResponse();
|
||||
return result.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -290,12 +290,11 @@ namespace kubecontrol
|
||||
|
||||
auto request = std::make_unique<curlpp::Easy>();
|
||||
|
||||
WriterMemoryClass mWriterChunk;
|
||||
curlpp::types::WriteFunctionFunctor functor = std::bind(&WriterMemoryClass::WriteMemoryCallback, &mWriterChunk, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(functor);
|
||||
|
||||
request->setOpt(test);
|
||||
|
||||
// request->setOpt(test);
|
||||
std::stringstream result;
|
||||
request->setOpt(cURLpp::Options::WriteStream(&result));
|
||||
|
||||
request->setOpt(new curlpp::options::HttpHeader(headers));
|
||||
|
||||
request->setOpt(new curlpp::options::Url(curlURL));
|
||||
@@ -306,9 +305,10 @@ namespace kubecontrol
|
||||
|
||||
|
||||
request->perform();
|
||||
std::string response = mWriterChunk.getResponse();
|
||||
|
||||
return response;
|
||||
|
||||
// std::string response = mWriterChunk.getResponse();
|
||||
std::string response = result.str();
|
||||
return response;
|
||||
}
|
||||
|
||||
void PodController::performForceStopRequest(std::string uuid)
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <kubecontrol/WriterMemoryClass.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@@ -54,13 +53,10 @@ namespace kubecontrol
|
||||
curlpp::Cleanup cleaner;
|
||||
curlpp::Easy request;
|
||||
|
||||
WriterMemoryClass mWriterChunk;
|
||||
|
||||
std::stringstream result;
|
||||
|
||||
curlpp::types::WriteFunctionFunctor functor = std::bind(&WriterMemoryClass::WriteMemoryCallback, &mWriterChunk, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
|
||||
curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(functor);
|
||||
request.setOpt(test);
|
||||
|
||||
request.setOpt(cURLpp::Options::WriteStream(&result));
|
||||
request.setOpt(new curlpp::options::HttpHeader(headers));
|
||||
|
||||
request.setOpt(new curlpp::options::Url(curlURL));
|
||||
@@ -73,7 +69,7 @@ namespace kubecontrol
|
||||
|
||||
|
||||
request.perform();
|
||||
auto response = mWriterChunk.getResponse();
|
||||
auto response = result.str();
|
||||
|
||||
|
||||
|
||||
@@ -96,11 +92,13 @@ namespace kubecontrol
|
||||
curlpp::Cleanup cleaner;
|
||||
curlpp::Easy request;
|
||||
|
||||
WriterMemoryClass mWriterChunk;
|
||||
curlpp::types::WriteFunctionFunctor functor = std::bind(&WriterMemoryClass::WriteMemoryCallback, &mWriterChunk, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(functor);
|
||||
request.setOpt(test);
|
||||
|
||||
// WriterMemoryClass mWriterChunk;
|
||||
// curlpp::types::WriteFunctionFunctor functor = std::bind(&WriterMemoryClass::WriteMemoryCallback, &mWriterChunk, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
// curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(functor);
|
||||
// request.setOpt(test);
|
||||
std::stringstream result;
|
||||
request.setOpt(cURLpp::Options::WriteStream(&result));
|
||||
|
||||
request.setOpt(new curlpp::options::HttpHeader(headers));
|
||||
|
||||
request.setOpt(new curlpp::options::Url(curlURL));
|
||||
@@ -148,7 +146,7 @@ namespace kubecontrol
|
||||
|
||||
|
||||
request.perform();
|
||||
auto response = mWriterChunk.getResponse();
|
||||
auto response = result.str();
|
||||
LOG_S(INFO)<<response;
|
||||
}
|
||||
|
||||
@@ -166,10 +164,9 @@ namespace kubecontrol
|
||||
curlpp::Cleanup cleaner;
|
||||
curlpp::Easy request;
|
||||
|
||||
WriterMemoryClass mWriterChunk;
|
||||
curlpp::types::WriteFunctionFunctor functor = std::bind(&WriterMemoryClass::WriteMemoryCallback, &mWriterChunk, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(functor);
|
||||
request.setOpt(test);
|
||||
std::stringstream result;
|
||||
request.setOpt(cURLpp::Options::WriteStream(&result));
|
||||
|
||||
|
||||
request.setOpt(new curlpp::options::HttpHeader(headers));
|
||||
|
||||
@@ -189,7 +186,7 @@ namespace kubecontrol
|
||||
|
||||
|
||||
request.perform();
|
||||
auto response = mWriterChunk.getResponse();
|
||||
auto response = result.str();
|
||||
// LOG_S(INFO)<<response;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user