I am new to C++ and curlpp, and I needed the header response and the response body from the curlpp response, but what is happening is I am getting both the things in the same string, is there any way or any flag which will help me in storing the header response and response body separately.
std::ostringstream respMsg;
request.setOpt(new PostFields(body));
request.setOpt(new PostFieldSize(body.size()));
request.setOpt(new Header(1));
request.setOpt(new curlpp::options::WriteStream(&respMsg));
if (curlpp::infos::ResponseCode::get(request) == 200){
// success
std::cout << respMsg.str() << std::endl;
json data = parse(respMsg.str())
} else {
// failure
std::cout << respMsg.str() << std::endl;
}
What I am expecting is in "if" part, I just need the json string, but I am getting header response + JSON string, which I am not able to separate, is there any setOPt flag or any way to get both the things separately, NOTE: I also need the header response in else part to print the error message. Any pointers are appreciated. Thanks in advance and sorry for bad English.